Skip to content

Commit

Permalink
pythongh-103906: Remove immortal refcounting in compile/marshal.c (py…
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Jun 5, 2023
1 parent cdfb201 commit 058b960
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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 @@ -900,10 +900,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 @@ -6355,7 +6355,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 @@ -1019,23 +1019,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

0 comments on commit 058b960

Please sign in to comment.