mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
bpo-46765: Replace Locally Cached Strings with Statically Initialized Objects (gh-31366)
https://bugs.python.org/issue46765
This commit is contained in:
parent
cff4d5c5d2
commit
1f455361ec
22 changed files with 192 additions and 526 deletions
|
@ -553,16 +553,11 @@ PyCode_New(int argcount, int kwonlyargcount,
|
|||
PyCodeObject *
|
||||
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
|
||||
{
|
||||
PyObject *emptystring = NULL;
|
||||
PyObject *nulltuple = NULL;
|
||||
PyObject *filename_ob = NULL;
|
||||
PyObject *funcname_ob = NULL;
|
||||
PyCodeObject *result = NULL;
|
||||
|
||||
emptystring = PyBytes_FromString("");
|
||||
if (emptystring == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
nulltuple = PyTuple_New(0);
|
||||
if (nulltuple == NULL) {
|
||||
goto failed;
|
||||
|
@ -576,6 +571,7 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
|
|||
goto failed;
|
||||
}
|
||||
|
||||
#define emptystring (PyObject *)&_Py_SINGLETON(bytes_empty)
|
||||
struct _PyCodeConstructor con = {
|
||||
.filename = filename_ob,
|
||||
.name = funcname_ob,
|
||||
|
@ -594,7 +590,6 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
|
|||
result = _PyCode_New(&con);
|
||||
|
||||
failed:
|
||||
Py_XDECREF(emptystring);
|
||||
Py_XDECREF(nulltuple);
|
||||
Py_XDECREF(funcname_ob);
|
||||
Py_XDECREF(filename_ob);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue