Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-90699: fix ref counting of static immortal strings #94850

Merged
merged 4 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix reference counting bug in :meth:`bool.__repr__`. Patch by Kumar Aditya.
2 changes: 1 addition & 1 deletion Modules/_io/textio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Objects/boolobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down