From 2ab2af8acd9da506608c9b38a1039853007489b4 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 30 Nov 2007 10:18:26 +0000 Subject: Partial fix for bug #1306 Multiple reinitializations of Python 3.0 failed on a system without a hardcoded default fs encoding. The patch makes sure that the default fs encoding is freed and reset to NULL on e.g. Linux. I've also taken the liberty to increase the debugging in Objects/object.c:_Py_ForgetReference(). The method is used to validate the reference chain. Reinitialization still fails in the 3rd round of my test suite: * ob object : type : str refcount: 0 address : 0x821c840 * op->_ob_prev->_ob_next object : type : str refcount: 0 address : 0x821c840 * op->_ob_next->_ob_prev object : bytearray(b'') type : bytearray refcount: 1 address : 0x826b838 Fatal Python error: UNREF invalid object --- Python/pythonrun.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Python/pythonrun.c') diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 0ba8646ab5..5766b2385e 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -502,6 +502,12 @@ Py_Finalize(void) /* Cleanup Unicode implementation */ _PyUnicode_Fini(); + /* reset file system default encoding */ + if (!Py_HasFileSystemDefaultEncoding) { + free((char*)Py_FileSystemDefaultEncoding); + Py_FileSystemDefaultEncoding = NULL; + } + /* XXX Still allocated: - various static ad-hoc pointers to interned strings - int and float free list blocks -- cgit v1.2.1