Skip to content

Commit 88516a6

Browse files
committed
When printing an unraisable error, don't print exceptions. before the name.
This duplicates the behavior whening normally printing exceptions.
1 parent a892554 commit 88516a6

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/test/test_generators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ def printsolution(self, x):
16811681
>>> g.next()
16821682
>>> del g
16831683
>>> sys.stderr.getvalue().startswith(
1684-
... "Exception exceptions.RuntimeError: 'generator ignored GeneratorExit' in "
1684+
... "Exception RuntimeError: 'generator ignored GeneratorExit' in "
16851685
... )
16861686
True
16871687
>>> sys.stderr = old
@@ -1798,7 +1798,7 @@ def printsolution(self, x):
17981798
... del l
17991799
... err = sys.stderr.getvalue().strip()
18001800
... err.startswith(
1801-
... "Exception exceptions.RuntimeError: RuntimeError() in <"
1801+
... "Exception RuntimeError: RuntimeError() in <"
18021802
... )
18031803
... err.endswith("> ignored")
18041804
... len(err.splitlines())

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
1212
Core and builtins
1313
-----------------
1414

15+
- When printing an unraisable error, don't print exceptions. before the name.
16+
This duplicates the behavior whening normally printing exceptions.
17+
1518
- Bug #1653736: Properly discard third argument to slot_nb_inplace_power.
1619

1720
- PEP 352: Raising a string exception now triggers a TypeError. Attempting to

Python/errors.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ PyErr_WriteUnraisable(PyObject *obj)
603603
PyFile_WriteString("<unknown>", f);
604604
else {
605605
char* modstr = PyString_AsString(moduleName);
606-
if (modstr)
606+
if (modstr &&
607+
strcmp(modstr, "exceptions") != 0)
607608
{
608609
PyFile_WriteString(modstr, f);
609610
PyFile_WriteString(".", f);

0 commit comments

Comments
 (0)