diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-30 10:18:26 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-30 10:18:26 (GMT) |
commit | c8967002353864e012567125d7824abaeeb31dd3 (patch) | |
tree | bfeda9fe43a3dd0025ebf69708cb6442c61d0e4f /Python | |
parent | a22e8bdfd92cd4f1bc3d60e91df6410c4efde6a0 (diff) | |
download | cpython-c8967002353864e012567125d7824abaeeb31dd3.zip cpython-c8967002353864e012567125d7824abaeeb31dd3.tar.gz cpython-c8967002353864e012567125d7824abaeeb31dd3.tar.bz2 |
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 : <refcnt 0 at 0x821c840>
type : str
refcount: 0
address : 0x821c840
* op->_ob_prev->_ob_next
object : <refcnt 0 at 0x821c840>
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
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 3 | ||||
-rw-r--r-- | Python/pythonrun.c | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index b109ba7..fb7e223 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -16,10 +16,13 @@ */ #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) const char *Py_FileSystemDefaultEncoding = "mbcs"; +const int Py_HasFileSystemDefaultEncoding = 1; #elif defined(__APPLE__) const char *Py_FileSystemDefaultEncoding = "utf-8"; +const int Py_HasFileSystemDefaultEncoding = 1; #else const char *Py_FileSystemDefaultEncoding = NULL; /* use default */ +const int Py_HasFileSystemDefaultEncoding = 0; #endif static PyObject * diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 0ba8646..5766b23 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 |