summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/fileobject.h1
-rw-r--r--Objects/object.c9
-rw-r--r--Python/bltinmodule.c3
-rw-r--r--Python/pythonrun.c6
4 files changed, 18 insertions, 1 deletions
diff --git a/Include/fileobject.h b/Include/fileobject.h
index 40d871a..0f40089 100644
--- a/Include/fileobject.h
+++ b/Include/fileobject.h
@@ -20,6 +20,7 @@ PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
If non-NULL, this is different than the default encoding for strings
*/
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
+PyAPI_DATA(const int) Py_HasFileSystemDefaultEncoding;
/* Internal API
diff --git a/Objects/object.c b/Objects/object.c
index df93a19..6414673 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1532,8 +1532,15 @@ _Py_ForgetReference(register PyObject *op)
if (op->ob_refcnt < 0)
Py_FatalError("UNREF negative refcnt");
if (op == &refchain ||
- op->_ob_prev->_ob_next != op || op->_ob_next->_ob_prev != op)
+ op->_ob_prev->_ob_next != op || op->_ob_next->_ob_prev != op) {
+ fprintf(stderr, "* ob\n");
+ _PyObject_Dump(op);
+ fprintf(stderr, "* op->_ob_prev->_ob_next\n");
+ _PyObject_Dump(op->_ob_prev->_ob_next);
+ fprintf(stderr, "* op->_ob_next->_ob_prev\n");
+ _PyObject_Dump(op->_ob_next->_ob_prev);
Py_FatalError("UNREF invalid object");
+ }
#ifdef SLOW_UNREF_CHECK
for (p = refchain._ob_next; p != &refchain; p = p->_ob_next) {
if (p == op)
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