run_file(): encode the filename with PyUnicode_EncodeFSDefault() instead of

PyUnicode_AsUTF8String()
This commit is contained in:
Victor Stinner 2010-10-17 19:34:51 +00:00
parent c049982ea5
commit e0f3268715
1 changed files with 2 additions and 2 deletions

View File

@ -280,14 +280,14 @@ run_file(FILE *fp, const wchar_t *filename, PyCompilerFlags *p_cf)
if (filename) {
unicode = PyUnicode_FromWideChar(filename, wcslen(filename));
if (unicode != NULL) {
bytes = PyUnicode_AsUTF8String(unicode);
bytes = PyUnicode_EncodeFSDefault(unicode);
Py_DECREF(unicode);
}
if (bytes != NULL)
filename_str = PyBytes_AsString(bytes);
else {
PyErr_Clear();
filename_str = "<decoding error>";
filename_str = "<encoding error>";
}
}
else