mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-103906: Remove immortal refcounting in compile/marshal.c (gh-103922)
This commit is contained in:
parent
cdfb201bfa
commit
058b960535
3 changed files with 8 additions and 8 deletions
|
@ -26,7 +26,7 @@ ellipsis_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
PyErr_SetString(PyExc_TypeError, "EllipsisType takes no arguments");
|
PyErr_SetString(PyExc_TypeError, "EllipsisType takes no arguments");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return Py_NewRef(Py_Ellipsis);
|
return Py_Ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -900,10 +900,10 @@ static PyObject*
|
||||||
merge_consts_recursive(PyObject *const_cache, PyObject *o)
|
merge_consts_recursive(PyObject *const_cache, PyObject *o)
|
||||||
{
|
{
|
||||||
assert(PyDict_CheckExact(const_cache));
|
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.
|
// No need to merge object and key.
|
||||||
if (o == Py_None || o == Py_Ellipsis) {
|
if (o == Py_None || o == Py_Ellipsis) {
|
||||||
return Py_NewRef(o);
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *key = _PyCode_ConstantKey(o);
|
PyObject *key = _PyCode_ConstantKey(o);
|
||||||
|
@ -6355,7 +6355,7 @@ compiler_error(struct compiler *c, location loc,
|
||||||
}
|
}
|
||||||
PyObject *loc_obj = PyErr_ProgramTextObject(c->c_filename, loc.lineno);
|
PyObject *loc_obj = PyErr_ProgramTextObject(c->c_filename, loc.lineno);
|
||||||
if (loc_obj == NULL) {
|
if (loc_obj == NULL) {
|
||||||
loc_obj = Py_NewRef(Py_None);
|
loc_obj = Py_None;
|
||||||
}
|
}
|
||||||
PyObject *args = Py_BuildValue("O(OiiOii)", msg, c->c_filename,
|
PyObject *args = Py_BuildValue("O(OiiOii)", msg, c->c_filename,
|
||||||
loc.lineno, loc.col_offset + 1, loc_obj,
|
loc.lineno, loc.col_offset + 1, loc_obj,
|
||||||
|
|
|
@ -1019,7 +1019,7 @@ r_object(RFILE *p)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_NONE:
|
case TYPE_NONE:
|
||||||
retval = Py_NewRef(Py_None);
|
retval = Py_None;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_STOPITER:
|
case TYPE_STOPITER:
|
||||||
|
@ -1027,15 +1027,15 @@ r_object(RFILE *p)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_ELLIPSIS:
|
case TYPE_ELLIPSIS:
|
||||||
retval = Py_NewRef(Py_Ellipsis);
|
retval = Py_Ellipsis;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_FALSE:
|
case TYPE_FALSE:
|
||||||
retval = Py_NewRef(Py_False);
|
retval = Py_False;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_TRUE:
|
case TYPE_TRUE:
|
||||||
retval = Py_NewRef(Py_True);
|
retval = Py_True;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_INT:
|
case TYPE_INT:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue