summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index a928fc4..6b8600b 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -29,7 +29,7 @@ int Py_HasFileSystemDefaultEncoding = 0;
int
_Py_SetFileSystemEncoding(PyObject *s)
{
- PyObject *defenc;
+ PyObject *defenc, *codec;
if (!PyUnicode_Check(s)) {
PyErr_BadInternalCall();
return -1;
@@ -37,6 +37,10 @@ _Py_SetFileSystemEncoding(PyObject *s)
defenc = _PyUnicode_AsDefaultEncodedString(s, NULL);
if (!defenc)
return -1;
+ codec = _PyCodec_Lookup(PyBytes_AsString(defenc));
+ if (codec == NULL)
+ return -1;
+ Py_DECREF(codec);
if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding)
/* A file system encoding was set at run-time */
free((char*)Py_FileSystemDefaultEncoding);