print_exception(): don't encode the module name to UTF-8

Replace _PyUnicode_AsString()+strcmp() with PyUnicode_CompareWithASCIIString().
This commit is contained in:
Victor Stinner 2013-11-07 00:12:30 +01:00
parent eaa2883d15
commit 937114f704
1 changed files with 2 additions and 3 deletions

View File

@ -1928,10 +1928,9 @@ print_exception(PyObject *f, PyObject *value)
err = PyFile_WriteString("<unknown>", f); err = PyFile_WriteString("<unknown>", f);
} }
else { else {
char* modstr = _PyUnicode_AsString(moduleName); if (PyUnicode_CompareWithASCIIString(moduleName, "builtins") != 0)
if (modstr && strcmp(modstr, "builtins"))
{ {
err = PyFile_WriteString(modstr, f); err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW);
err += PyFile_WriteString(".", f); err += PyFile_WriteString(".", f);
} }
Py_DECREF(moduleName); Py_DECREF(moduleName);