mirror of
https://github.com/python/cpython.git
synced 2025-09-05 00:11:10 +00:00
Issue #17408: Avoid using an obsolete instance of the copyreg module when the interpreter is shutdown and then started again.
This commit is contained in:
commit
df6931dbbc
4 changed files with 22 additions and 8 deletions
|
@ -219,6 +219,7 @@ PyAPI_FUNC(void) PyFloat_Fini(void);
|
||||||
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
|
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
|
||||||
PyAPI_FUNC(void) _PyGC_Fini(void);
|
PyAPI_FUNC(void) _PyGC_Fini(void);
|
||||||
PyAPI_FUNC(void) PySlice_Fini(void);
|
PyAPI_FUNC(void) PySlice_Fini(void);
|
||||||
|
PyAPI_FUNC(void) _PyType_Fini(void);
|
||||||
|
|
||||||
PyAPI_DATA(PyThreadState *) _Py_Finalizing;
|
PyAPI_DATA(PyThreadState *) _Py_Finalizing;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #17408: Avoid using an obsolete instance of the copyreg module when
|
||||||
|
the interpreter is shutdown and then started again.
|
||||||
|
|
||||||
- Issue #5845: Enable tab-completion in the interactive interpreter by
|
- Issue #5845: Enable tab-completion in the interactive interpreter by
|
||||||
default, thanks to a new sys.__interactivehook__.
|
default, thanks to a new sys.__interactivehook__.
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Cached lookup of the copyreg module, for faster __reduce__ calls */
|
||||||
|
|
||||||
|
static PyObject *cached_copyreg_module = NULL;
|
||||||
|
|
||||||
/* Support type attribute cache */
|
/* Support type attribute cache */
|
||||||
|
|
||||||
/* The cache can keep references to the names alive for longer than
|
/* The cache can keep references to the names alive for longer than
|
||||||
|
@ -68,6 +72,15 @@ PyType_ClearCache(void)
|
||||||
return cur_version_tag;
|
return cur_version_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_PyType_Fini(void)
|
||||||
|
{
|
||||||
|
PyType_ClearCache();
|
||||||
|
/* Need to forget our obsolete instance of the copyreg module at
|
||||||
|
* interpreter shutdown (issue #17408). */
|
||||||
|
Py_CLEAR(cached_copyreg_module);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyType_Modified(PyTypeObject *type)
|
PyType_Modified(PyTypeObject *type)
|
||||||
{
|
{
|
||||||
|
@ -3339,19 +3352,18 @@ static PyObject *
|
||||||
import_copyreg(void)
|
import_copyreg(void)
|
||||||
{
|
{
|
||||||
static PyObject *copyreg_str;
|
static PyObject *copyreg_str;
|
||||||
static PyObject *mod_copyreg = NULL;
|
|
||||||
|
|
||||||
if (!copyreg_str) {
|
if (!copyreg_str) {
|
||||||
copyreg_str = PyUnicode_InternFromString("copyreg");
|
copyreg_str = PyUnicode_InternFromString("copyreg");
|
||||||
if (copyreg_str == NULL)
|
if (copyreg_str == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!mod_copyreg) {
|
if (!cached_copyreg_module) {
|
||||||
mod_copyreg = PyImport_Import(copyreg_str);
|
cached_copyreg_module = PyImport_Import(copyreg_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_XINCREF(mod_copyreg);
|
Py_XINCREF(cached_copyreg_module);
|
||||||
return mod_copyreg;
|
return cached_copyreg_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -524,9 +524,6 @@ Py_Finalize(void)
|
||||||
/* Disable signal handling */
|
/* Disable signal handling */
|
||||||
PyOS_FiniInterrupts();
|
PyOS_FiniInterrupts();
|
||||||
|
|
||||||
/* Clear type lookup cache */
|
|
||||||
PyType_ClearCache();
|
|
||||||
|
|
||||||
/* Collect garbage. This may call finalizers; it's nice to call these
|
/* Collect garbage. This may call finalizers; it's nice to call these
|
||||||
* before all modules are destroyed.
|
* before all modules are destroyed.
|
||||||
* XXX If a __del__ or weakref callback is triggered here, and tries to
|
* XXX If a __del__ or weakref callback is triggered here, and tries to
|
||||||
|
@ -632,6 +629,7 @@ Py_Finalize(void)
|
||||||
PyFloat_Fini();
|
PyFloat_Fini();
|
||||||
PyDict_Fini();
|
PyDict_Fini();
|
||||||
PySlice_Fini();
|
PySlice_Fini();
|
||||||
|
_PyType_Fini();
|
||||||
|
|
||||||
/* Cleanup Unicode implementation */
|
/* Cleanup Unicode implementation */
|
||||||
_PyUnicode_Fini();
|
_PyUnicode_Fini();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue