diff Python/import.c @ 65425:c99cf9102476

find_module(): use FS encoding to display the missing __init__ warning
author Victor Stinner <victor.stinner@haypocalc.com>
date Sun, 17 Oct 2010 02:07:09 +0000
parents fd5135cbd928
children 448ab7516c0a
line wrap: on
line diff
--- a/Python/import.c	Sun Oct 17 01:41:09 2010 +0000
+++ b/Python/import.c	Sun Oct 17 02:07:09 2010 +0000
@@ -1736,14 +1736,16 @@
                 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