diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-17 02:07:09 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-17 02:07:09 (GMT) |
commit | ed7916dd001d5d49b5be04a745c2f83826b27fe2 (patch) | |
tree | b8801d6bb546ba100ed03dcf72347f3484f0ba50 /Python/import.c | |
parent | e3874ed7dd978292d43ccdef1ad7896dfec663a7 (diff) | |
download | cpython-ed7916dd001d5d49b5be04a745c2f83826b27fe2.zip cpython-ed7916dd001d5d49b5be04a745c2f83826b27fe2.tar.gz cpython-ed7916dd001d5d49b5be04a745c2f83826b27fe2.tar.bz2 |
find_module(): use FS encoding to display the missing __init__ warning
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c index 6715dc9..523a1c0 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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 |