]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
find_module(): use FS encoding to display the missing __init__ warning
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 17 Oct 2010 02:07:09 +0000 (02:07 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 17 Oct 2010 02:07:09 +0000 (02:07 +0000)
Python/import.c

index 6715dc929dab8a6b0cefc94778ab82a6ceefc574..523a1c04db262157d1fd45a38a16b2e45aafc417 100644 (file)
@@ -1736,14 +1736,16 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
                 return &fd_package;
             }
             else {
-                char warnstr[MAXPATHLEN+80];
-                sprintf(warnstr, "Not importing directory "
-                    "'%.*s': missing __init__.py",
-                    MAXPATHLEN, buf);
-                if (PyErr_WarnEx(PyExc_ImportWarning,
-                                 warnstr, 1)) {
+                int err;
+                PyObject *unicode = PyUnicode_DecodeFSDefault(buf);
+                if (unicode == NULL)
+                    return NULL;
+                err = PyErr_WarnFormat(PyExc_ImportWarning, 1,
+                    "Not importing directory '%U': missing __init__.py",
+                    unicode);
+                Py_DECREF(unicode);
+                if (err)
                     return NULL;
-                }
             }
         }
 #endif