-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
191e313
commit de86073
Showing
9 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
from unittest import mock | ||
|
||
from test.support import captured_stderr | ||
import idlelib.run as idlerun | ||
|
||
|
||
class RunTest(unittest.TestCase): | ||
def test_print_exception_unhashable(self): | ||
class UnhashableException(Exception): | ||
def __eq__(self, other): | ||
return True | ||
|
||
ex1 = UnhashableException('ex1') | ||
ex2 = UnhashableException('ex2') | ||
try: | ||
raise ex2 from ex1 | ||
except UnhashableException: | ||
try: | ||
raise ex1 | ||
except UnhashableException: | ||
with captured_stderr() as output: | ||
with mock.patch.object(idlerun, | ||
'cleanup_traceback') as ct: | ||
ct.side_effect = lambda t, e: t | ||
idlerun.print_exception() | ||
|
||
tb = output.getvalue().strip().splitlines() | ||
self.assertEqual(11, len(tb)) | ||
self.assertIn('UnhashableException: ex2', tb[3]) | ||
self.assertIn('UnhashableException: ex1', tb[10]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main(verbosity=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Core and Builtins/2017-10-17-13-29-19.bpo-28603._-oia3.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Print the full context/cause chain of exceptions on interpreter exit, even | ||
if an exception in the chain is unhashable or compares equal to later ones. | ||
Patch by Zane Bitter. |
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/IDLE/2017-10-17-13-26-13.bpo-28603.TMEQfp.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix a TypeError that caused a shell restart when printing a traceback that | ||
includes an exception that is unhashable. Patch by Zane Bitter. |
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Library/2017-10-17-12-29-18.bpo-28603.tGuX2C.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
traceback: Fix a TypeError that occurred during printing of exception | ||
tracebacks when either the current exception or an exception in its | ||
context/cause chain is unhashable. Patch by Zane Bitter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters