Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 937114f

Browse files
committed
print_exception(): don't encode the module name to UTF-8
Replace _PyUnicode_AsString()+strcmp() with PyUnicode_CompareWithASCIIString().
1 parent eaa2883 commit 937114f

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Python/pythonrun.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,10 +1928,9 @@ print_exception(PyObject *f, PyObject *value)
19281928
err = PyFile_WriteString("<unknown>", f);
19291929
}
19301930
else {
1931-
char* modstr = _PyUnicode_AsString(moduleName);
1932-
if (modstr && strcmp(modstr, "builtins"))
1931+
if (PyUnicode_CompareWithASCIIString(moduleName, "builtins") != 0)
19331932
{
1934-
err = PyFile_WriteString(modstr, f);
1933+
err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW);
19351934
err += PyFile_WriteString(".", f);
19361935
}
19371936
Py_DECREF(moduleName);

0 commit comments

Comments
 (0)