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-103906: Remove immortal refcounting in compile/marshal.c #103922

Merged
merged 4 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Objects/sliceobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ellipsis_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyErr_SetString(PyExc_TypeError, "EllipsisType takes no arguments");
return NULL;
}
return Py_NewRef(Py_Ellipsis);
return Py_Ellipsis;
}

static void
Expand Down
6 changes: 3 additions & 3 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,10 +892,10 @@ static PyObject*
merge_consts_recursive(PyObject *const_cache, PyObject *o)
{
assert(PyDict_CheckExact(const_cache));
// None and Ellipsis are singleton, and key is the singleton.
// None and Ellipsis are immortal objects, and key is the singleton.
// No need to merge object and key.
if (o == Py_None || o == Py_Ellipsis) {
return Py_NewRef(o);
return o;
}

PyObject *key = _PyCode_ConstantKey(o);
Expand Down Expand Up @@ -5706,7 +5706,7 @@ compiler_error(struct compiler *c, location loc,
}
PyObject *loc_obj = PyErr_ProgramTextObject(c->c_filename, loc.lineno);
if (loc_obj == NULL) {
loc_obj = Py_NewRef(Py_None);
loc_obj = Py_None;
}
PyObject *args = Py_BuildValue("O(OiiOii)", msg, c->c_filename,
loc.lineno, loc.col_offset + 1, loc_obj,
Expand Down
8 changes: 4 additions & 4 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,23 +1015,23 @@ r_object(RFILE *p)
break;

case TYPE_NONE:
retval = Py_NewRef(Py_None);
retval = Py_None;
break;

case TYPE_STOPITER:
retval = Py_NewRef(PyExc_StopIteration);
break;

case TYPE_ELLIPSIS:
retval = Py_NewRef(Py_Ellipsis);
retval = Py_Ellipsis;
break;

case TYPE_FALSE:
retval = Py_NewRef(Py_False);
retval = Py_False;
break;

case TYPE_TRUE:
retval = Py_NewRef(Py_True);
retval = Py_True;
break;

case TYPE_INT:
Expand Down