diff options
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/main.c | 11 |
2 files changed, 10 insertions, 4 deletions
@@ -12,6 +12,9 @@ What's New in Python 3.1 alpha 0 Core and Builtins ----------------- +- Issue #4747: When the terminal does not use utf-8, executing a script with + non-ascii characters in its name could fail with a "SyntaxError: None" error. + - Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open file with `bytes' filename on Windows. diff --git a/Modules/main.c b/Modules/main.c index 78913ee..3025d09 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -600,18 +600,21 @@ Py_Main(int argc, wchar_t **argv) } if (sts==-1) { - char cfilename[PATH_MAX]; + PyObject *filenameObj = NULL; char *p_cfilename = "<stdin>"; if (filename) { - size_t r = wcstombs(cfilename, filename, PATH_MAX); - p_cfilename = cfilename; - if (r == (size_t)-1 || r >= PATH_MAX) + filenameObj = PyUnicode_FromWideChar( + filename, wcslen(filename)); + if (filenameObj != NULL) + p_cfilename = _PyUnicode_AsString(filenameObj); + else p_cfilename = "<decoding error>"; } sts = PyRun_AnyFileExFlags( fp, p_cfilename, filename != NULL, &cf) != 0; + Py_XDECREF(filenameObj); } } |