]> granicus.if.org Git - python/commitdiff
_Py_fopen now allows bytes filenames under non-Windows platforms.
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 19 Dec 2011 17:19:06 +0000 (18:19 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 19 Dec 2011 17:19:06 +0000 (18:19 +0100)
Python/fileutils.c

index 8c049e02af5879938fdb403cd9a70dd79e0c36a4..1e71431c0090392fb7610f5d179fa12f3198b441 100644 (file)
@@ -321,8 +321,8 @@ _Py_fopen(PyObject *path, const char *mode)
     return _wfopen(wpath, wmode);
 #else
     FILE *f;
-    PyObject *bytes = PyUnicode_EncodeFSDefault(path);
-    if (bytes == NULL)
+    PyObject *bytes;
+    if (!PyUnicode_FSConverter(path, &bytes))
         return NULL;
     f = fopen(PyBytes_AS_STRING(bytes), mode);
     Py_DECREF(bytes);