8000 gh-135511 Fixed `NameError` and `AttributeError` lack of the message in IDLE by Locked-chess-official · Pull Request #135526 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-135511 Fixed NameError and AttributeError lack of the message in IDLE #135526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update test_run.py
  • Loading branch information
Locked-chess-official authored Jun 18, 2025
commit 2b182013df7bed9154d3ab238750cceac26805b9
13 changes: 10 additions & 3 deletions Lib/idlelib/idle_test/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,24 @@ def __eq__(self, other):
('int.reel', AttributeError,
"type object 'int' has no attribute 'reel'. "
"Did you mean: 'real'?\n"),
('raise NameError("123\\n456")', NameError, "123\n456"),
)

@force_not_colorized
def test_get_message(self):
for code, exc, msg in self.data:
with self.subTest(code=code):
try:
eval(compile(code, '', 'eval'))
if "raise " not in code:
eval(compile(code, '', 'eval'))
else:
exec(compile(code, '', 'exec'))
except exc:
typ, val, tb = sys.exc_info()
actual = run.get_message_lines(typ, val, tb)[0]
if "raise " in code:
actual = run.print_exception(in_test=True)
else:
typ, val, tb = sys.exc_info()
actual = run.get_message_lines(typ, val, tb)[0]
expect = f'{exc.__name__}: {msg}'
self.assertEqual(actual, expect)

Expand Down
Loading
0