From cf6286221772ab0f8702dc509715cfdf508256d5 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Thu, 14 Jul 2022 10:01:15 +0000 Subject: [PATCH 1/2] fix recounting of immortal objects --- Modules/_io/textio.c | 2 +- Objects/boolobject.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 660396b8b03ead..52f72cfb7aa5cf 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -2239,7 +2239,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit) Py_CLEAR(chunks); } if (line == NULL) { - line = &_Py_STR(empty); + line = Py_NewRef(&_Py_STR(empty)); } return line; diff --git a/Objects/boolobject.c b/Objects/boolobject.c index ff7218760ab361..8a20e368d4a42b 100644 --- a/Objects/boolobject.c +++ b/Objects/boolobject.c @@ -9,7 +9,8 @@ static PyObject * bool_repr(PyObject *self) { - return self == Py_True ? &_Py_ID(True) : &_Py_ID(False); + PyObject *res = self == Py_True ? &_Py_ID(True) : &_Py_ID(False); + return Py_NewRef(res); } /* Function to return a bool from a C long */ From f530250c6a4ef3e1a304c765ad8737f63052c1f6 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 14 Jul 2022 10:07:54 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-07-14-10-07-53.gh-issue-90699.x3aG9m.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-07-14-10-07-53.gh-issue-90699.x3aG9m.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-14-10-07-53.gh-issue-90699.x3aG9m.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-14-10-07-53.gh-issue-90699.x3aG9m.rst new file mode 100644 index 00000000000000..795f4df987eb90 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-14-10-07-53.gh-issue-90699.x3aG9m.rst @@ -0,0 +1 @@ +Fix reference counting bug in :meth:`bool.__repr__`. Patch by Kumar Aditya.