diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-07-20 06:23:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-20 06:23:30 (GMT) |
commit | 1834133e66d95a143c9df5f068b3109927aefd65 (patch) | |
tree | 150d0239e46202529647d36e0f4146a9c798ac2a | |
parent | 88e4eeba25df999866b23448b95dce2769c2da86 (diff) | |
download | cpython-1834133e66d95a143c9df5f068b3109927aefd65.zip cpython-1834133e66d95a143c9df5f068b3109927aefd65.tar.gz cpython-1834133e66d95a143c9df5f068b3109927aefd65.tar.bz2 |
GH-90699: fix ref counting of static immortal strings (gh-94850)
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-07-14-10-07-53.gh-issue-90699.x3aG9m.rst | 1 | ||||
-rw-r--r-- | Modules/_io/textio.c | 2 | ||||
-rw-r--r-- | Objects/boolobject.c | 3 |
3 files changed, 4 insertions, 2 deletions
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 0000000..795f4df --- /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. diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 89094d6..3369694 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -2244,7 +2244,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 ff72187..8a20e36 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 */ |