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

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1834133

Browse files
GH-90699: fix ref counting of static immortal strings (gh-94850)
1 parent 88e4eeb commit 1834133

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