8000 GH-90699: fix ref counting of static immortal strings (gh-94850) · python/cpython@84d58ad · GitHub
[go: up one dir, main page]

Skip to content

Commit 84d58ad

Browse files
GH-90699: fix ref counting of static immortal strings (gh-94850)
(cherry picked from commit 1834133) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
1 parent b3aec3e commit 84d58ad

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix reference counting bug in :meth:`bool.__repr__`. Patch by Kumar Aditya.

Modules/_io/textio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit)
22442244
Py_CLEAR(chunks);
22452245
}
22462246
if (line == NULL) {
2247-
line = &_Py_STR(empty);
2247+
line = Py_NewRef(&_Py_STR(empty));
22482248
}
22492249

22502250
return line;

Objects/boolobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
static PyObject *
1010
bool_repr(PyObject *self)
1111
{
12-
return self == Py_True ? &_Py_ID(True) : &_Py_ID(False);
12+
PyObject *res = self == Py_True ? &_Py_ID(True) : &_Py_ID(False);
13+
return Py_NewRef(res);
1314
}
1415

1516
/* Function to return a bool from a C long */

0 commit comments

Comments
 (0)
0