diff --git a/Python/pythonrun.c b/Python/pythonrun.c index e510e6f78ab..e0c863811a4 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1928,10 +1928,9 @@ print_exception(PyObject *f, PyObject *value) err = PyFile_WriteString("", f); } else { - char* modstr = _PyUnicode_AsString(moduleName); - if (modstr && strcmp(modstr, "builtins")) + if (PyUnicode_CompareWithASCIIString(moduleName, "builtins") != 0) { - err = PyFile_WriteString(modstr, f); + err = PyFile_WriteObject(moduleName, f, Py_PRINT_RAW); err += PyFile_WriteString(".", f); } Py_DECREF(moduleName);