mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-41031: Match C and Python code formatting of unprintable exceptions and exceptions in the __main__ module. (GH-28139)
This commit is contained in:
parent
b01fd533fe
commit
9e31b3952f
6 changed files with 55 additions and 14 deletions
|
@ -25,6 +25,7 @@ extern char *strerror(int);
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
_Py_IDENTIFIER(__main__);
|
||||
_Py_IDENTIFIER(__module__);
|
||||
_Py_IDENTIFIER(builtins);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
@ -1297,7 +1298,8 @@ write_unraisable_exc_file(PyThreadState *tstate, PyObject *exc_type,
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (!_PyUnicode_EqualToASCIIId(modulename, &PyId_builtins)) {
|
||||
if (!_PyUnicode_EqualToASCIIId(modulename, &PyId_builtins) &&
|
||||
!_PyUnicode_EqualToASCIIId(modulename, &PyId___main__)) {
|
||||
if (PyFile_WriteObject(modulename, file, Py_PRINT_RAW) < 0) {
|
||||
Py_DECREF(modulename);
|
||||
return -1;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue