bpo-41031: Match C and Python code formatting of unprintable exceptions and exceptions in the __main__ module. (GH-28139)

This commit is contained in:
Irit Katriel 2021-09-05 16:54:13 +01:00 committed by GitHub
parent b01fd533fe
commit 9e31b3952f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 14 deletions

View file

@ -35,6 +35,7 @@
#endif
_Py_IDENTIFIER(__main__);
_Py_IDENTIFIER(builtins);
_Py_IDENTIFIER(excepthook);
_Py_IDENTIFIER(flush);
@ -974,7 +975,8 @@ print_exception(PyObject *f, PyObject *value)
err = PyFile_WriteString("<unknown>", f);
}
else {
if (!_PyUnicode_EqualToASCIIId(modulename, &PyId_builtins))
if (!_PyUnicode_EqualToASCIIId(modulename, &PyId_builtins) &&
!_PyUnicode_EqualToASCIIId(modulename, &PyId___main__))
{
err = PyFile_WriteObject(modulename, f, Py_PRINT_RAW);
err += PyFile_WriteString(".", f);