]> granicus.if.org Git - python/commitdiff
posix_error_with_allocated_filename() decodes the filename with
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 8 May 2010 00:36:42 +0000 (00:36 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 8 May 2010 00:36:42 +0000 (00:36 +0000)
PyUnicode_DecodeFSDefaultAndSize() and call
PyErr_SetFromErrnoWithFilenameObject() instead of
PyErr_SetFromErrnoWithFilename()

Modules/posixmodule.c

index a48f233da79641fcc0dff26fbcce768550d5e414..8aea64008377d4b1d245f2a049d4fa801ca32762 100644 (file)
@@ -559,9 +559,13 @@ posix_error_with_unicode_filename(Py_UNICODE* name)
 static PyObject *
 posix_error_with_allocated_filename(PyObject* name)
 {
-    PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError,
-                                                  PyBytes_AsString(name));
+    PyObject *name_str, *rc;
+    name_str = PyUnicode_DecodeFSDefaultAndSize(PyBytes_AsString(name),
+                                                PyBytes_GET_SIZE(name));
     Py_DECREF(name);
+    rc = PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError,
+                                              name_str);
+    Py_XDECREF(name_str);
     return rc;
 }