summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-22 11:27:50 (GMT)
committerGitHub <noreply@github.com>2019-11-22 11:27:50 (GMT)
commit3d4833488a173c16446c3f94f58f05e2d13c5dee (patch)
tree37e5ab1eef1a29ed5aaf588a5d883107974ef9e1 /Objects
parent310e2d25170a88ef03f6fd31efcc899fe062da2c (diff)
downloadcpython-3d4833488a173c16446c3f94f58f05e2d13c5dee.zip
cpython-3d4833488a173c16446c3f94f58f05e2d13c5dee.tar.gz
cpython-3d4833488a173c16446c3f94f58f05e2d13c5dee.tar.bz2
bpo-38858: Call _PyUnicode_Fini() in Py_EndInterpreter() (GH-17330)
Py_EndInterpreter() now clears the filesystem codec.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 5ae0af8..89e45d0 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -15929,34 +15929,37 @@ _PyUnicode_EnableLegacyWindowsFSEncoding(void)
void
-_PyUnicode_Fini(void)
+_PyUnicode_Fini(PyThreadState *tstate)
{
+ if (_Py_IsMainInterpreter(tstate)) {
#if defined(WITH_VALGRIND) || defined(__INSURE__)
- /* Insure++ is a memory analysis tool that aids in discovering
- * memory leaks and other memory problems. On Python exit, the
- * interned string dictionaries are flagged as being in use at exit
- * (which it is). Under normal circumstances, this is fine because
- * the memory will be automatically reclaimed by the system. Under
- * memory debugging, it's a huge source of useless noise, so we
- * trade off slower shutdown for less distraction in the memory
- * reports. -baw
- */
- unicode_release_interned();
+ /* Insure++ is a memory analysis tool that aids in discovering
+ * memory leaks and other memory problems. On Python exit, the
+ * interned string dictionaries are flagged as being in use at exit
+ * (which it is). Under normal circumstances, this is fine because
+ * the memory will be automatically reclaimed by the system. Under
+ * memory debugging, it's a huge source of useless noise, so we
+ * trade off slower shutdown for less distraction in the memory
+ * reports. -baw
+ */
+ unicode_release_interned();
#endif /* __INSURE__ */
- Py_CLEAR(unicode_empty);
+ Py_CLEAR(unicode_empty);
- for (Py_ssize_t i = 0; i < 256; i++) {
- Py_CLEAR(unicode_latin1[i]);
+ for (Py_ssize_t i = 0; i < 256; i++) {
+ Py_CLEAR(unicode_latin1[i]);
+ }
+ _PyUnicode_ClearStaticStrings();
+ (void)PyUnicode_ClearFreeList();
}
- _PyUnicode_ClearStaticStrings();
- (void)PyUnicode_ClearFreeList();
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
PyMem_RawFree(interp->fs_codec.encoding);
interp->fs_codec.encoding = NULL;
PyMem_RawFree(interp->fs_codec.errors);
interp->fs_codec.errors = NULL;
+ interp->config.filesystem_errors = _Py_ERROR_UNKNOWN;
}