[Python-checkins] cpython (3.2): sys.getfilesystemencoding() raises a RuntimeError if initfsencoding() was not

victor.stinner python-checkins at python.org
Thu Mar 31 13:56:56 CEST 2011


http://hg.python.org/cpython/rev/a00b9a5688da
changeset:   69077:a00b9a5688da
branch:      3.2
parent:      69068:9b12af6e9ea9
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Thu Mar 31 13:39:03 2011 +0200
summary:
  sys.getfilesystemencoding() raises a RuntimeError if initfsencoding() was not
called yet: detect bootstrap (startup) issues earlier.

files:
  Misc/NEWS          |  3 +++
  Python/sysmodule.c |  5 +++--
  2 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,9 @@
 Library
 -------
 
+- sys.getfilesystemencoding() raises a RuntimeError if initfsencoding() was not
+  called yet: detect bootstrap (startup) issues earlier.
+
 - Issue #11618: Fix the timeout logic in threading.Lock.acquire() under Windows.
 
 - Issue #11256: Fix inspect.getcallargs on functions that take only keyword
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -259,8 +259,9 @@
 {
     if (Py_FileSystemDefaultEncoding)
         return PyUnicode_FromString(Py_FileSystemDefaultEncoding);
-    Py_INCREF(Py_None);
-    return Py_None;
+    PyErr_SetString(PyExc_RuntimeError,
+                    "filesystem encoding is not initialized");
+    return NULL;
 }
 
 PyDoc_STRVAR(getfilesystemencoding_doc,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list