Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb52020

Browse files
committed
Issue #19512: pickle now uses an identifier to only create the Unicode string
"modules" once
1 parent cab75e3 commit bb52020

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Modules/_pickle.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ static PyObject *empty_tuple = NULL;
136136
/* For looking up name pairs in copyreg._extension_registry. */
137137
static PyObject *two_tuple = NULL;
138138

139+
_Py_IDENTIFIER(modules);
140+
139141
static int
140142
stack_underflow(void)
141143
{
@@ -1363,7 +1365,7 @@ whichmodule(PyObject *global, PyObject *global_name)
13631365
return NULL;
13641366

13651367
search:
1366-
modules_dict = PySys_GetObject("modules");
1368+
modules_dict = _PySys_GetObjectId(&PyId_modules);
13671369
if (modules_dict == NULL) {
13681370
PyErr_SetString(PyExc_RuntimeError, "unable to get sys.modules");
13691371
return NULL;
@@ -5548,7 +5550,7 @@ Unpickler_find_class(UnpicklerObject *self, PyObject *args)
55485550
}
55495551
}
55505552

5551-
modules_dict = PySys_GetObject("modules");
5553+
modules_dict = _PySys_GetObjectId(&PyId_modules);
55525554
if (modules_dict == NULL) {
55535555
PyErr_SetString(PyExc_RuntimeError, "unable to get sys.modules");
55545556
return NULL;

0 commit comments

Comments
 (0)