From: Victor Stinner Date: Thu, 31 Mar 2011 11:39:03 +0000 (+0200) Subject: sys.getfilesystemencoding() raises a RuntimeError if initfsencoding() was not X-Git-Tag: v3.2.1b1~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27181ac778fdb8432d79f280922eac0f70af5194;p=python sys.getfilesystemencoding() raises a RuntimeError if initfsencoding() was not called yet: detect bootstrap (startup) issues earlier. --- diff --git a/Misc/NEWS b/Misc/NEWS index 5cc5963d6e..da09cc99b5 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -49,6 +49,9 @@ Core and Builtins 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 index 8d44135be1..5664646381 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -259,8 +259,9 @@ sys_getfilesystemencoding(PyObject *self) { 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,