mirror of https://github.com/python/cpython
Py_Finalize(): Reverted recent changes that tried to move the
PYTHONDUMPREFS output after most teardown. Attempts to use PYTHONDUMPREFS with the Zope3 test suite died with Py_FatalError(), since _Py_PrintReferences() can end up executing arbitrary Python code (for objects that override __repr__), and that requires an intact interpreter.
This commit is contained in:
parent
d3ab37f1df
commit
9cf25ce3a0
|
@ -270,6 +270,17 @@ Py_Finalize(void)
|
||||||
fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
|
fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Py_TRACE_REFS
|
||||||
|
/* Display all objects still alive -- this can invoke arbitrary
|
||||||
|
* __repr__ overrides, so requires a mostly-intact interpreter.
|
||||||
|
* Alas, a lot of stuff may still be alive now that will be cleaned
|
||||||
|
* up later.
|
||||||
|
*/
|
||||||
|
if (Py_GETENV("PYTHONDUMPREFS")) {
|
||||||
|
_Py_PrintReferences(stderr);
|
||||||
|
}
|
||||||
|
#endif /* Py_TRACE_REFS */
|
||||||
|
|
||||||
/* Now we decref the exception classes. After this point nothing
|
/* Now we decref the exception classes. After this point nothing
|
||||||
can raise an exception. That's okay, because each Fini() method
|
can raise an exception. That's okay, because each Fini() method
|
||||||
below has been checked to make sure no exceptions are ever
|
below has been checked to make sure no exceptions are ever
|
||||||
|
@ -306,14 +317,6 @@ Py_Finalize(void)
|
||||||
|
|
||||||
PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
|
PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
|
||||||
|
|
||||||
#ifdef Py_TRACE_REFS
|
|
||||||
/* Dump references -- this may implicitly need the thread state,
|
|
||||||
so this is the last possible place where we can do this. */
|
|
||||||
if (Py_GETENV("PYTHONDUMPREFS")) {
|
|
||||||
_Py_PrintReferences(stderr);
|
|
||||||
}
|
|
||||||
#endif /* Py_TRACE_REFS */
|
|
||||||
|
|
||||||
#ifdef PYMALLOC_DEBUG
|
#ifdef PYMALLOC_DEBUG
|
||||||
if (Py_GETENV("PYTHONMALLOCSTATS"))
|
if (Py_GETENV("PYTHONMALLOCSTATS"))
|
||||||
_PyObject_DebugMallocStats();
|
_PyObject_DebugMallocStats();
|
||||||
|
|
Loading…
Reference in New Issue