mirror of
https://github.com/python/cpython.git
synced 2025-10-19 13:18:16 +00:00
Update a comment about why the __module__ can sometime be NULL.
Initialize last_string and arg member of Unpickler.
This commit is contained in:
parent
b646aa1789
commit
0e7aa8c13c
1 changed files with 6 additions and 3 deletions
|
@ -691,9 +691,9 @@ whichmodule(PyObject *global, PyObject *global_name)
|
||||||
|
|
||||||
module_name = PyObject_GetAttr(global, module_str);
|
module_name = PyObject_GetAttr(global, module_str);
|
||||||
|
|
||||||
/* In some rare cases (e.g., random.getrandbits), __module__ can be
|
/* In some rare cases (e.g., bound methods of extension types),
|
||||||
None. If it is so, then search sys.modules for the module of
|
__module__ can be None. If it is so, then search sys.modules
|
||||||
global. */
|
for the module of global. */
|
||||||
if (module_name == Py_None) {
|
if (module_name == Py_None) {
|
||||||
Py_DECREF(module_name);
|
Py_DECREF(module_name);
|
||||||
goto search;
|
goto search;
|
||||||
|
@ -4447,6 +4447,9 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds)
|
||||||
if (self->memo == NULL)
|
if (self->memo == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
self->last_string = NULL;
|
||||||
|
self->arg = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue