Skip to content

gh-152490: Fix TypeError when formatting SyntaxError with msg=NotImplemented in traceback.py#152495

Open
Aniketsy wants to merge 7 commits into
python:mainfrom
Aniketsy:fix-152490
Open

gh-152490: Fix TypeError when formatting SyntaxError with msg=NotImplemented in traceback.py#152495
Aniketsy wants to merge 7 commits into
python:mainfrom
Aniketsy:fix-152490

Conversation

@Aniketsy

@Aniketsy Aniketsy commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Comment thread Lib/test/test_traceback.py Outdated
Comment on lines +628 to +631
def test_syntax_error_with_not_implemented_msg(self):
exc = SyntaxError(NotImplemented)
lines = traceback.format_exception_only(type(exc), exc)
self.assertIsInstance("".join(lines), str)

@picnixz picnixz Jun 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put that text under test_format_exception_only_exc please and rename it test_format_syntax_error and add an additoinal case inside it that checks a legitimate SyntaxError.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review, i've updated with the changes.

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no opinion on the test change.

Comment thread Misc/NEWS.d/next/Library/2026-06-28-14-37-01.gh-issue-152490.A8qLbF.rst Outdated
Comment thread Lib/traceback.py Outdated
@bedevere-app

bedevere-app Bot commented Jun 28, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Aniketsy and others added 2 commits June 29, 2026 06:37
…8qLbF.rst

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
with self.assertRaisesRegex(TypeError, 'required positional argument'):
traceback.format_exception(exc=e)

def test_format_exception_only_exc(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this name actually.

output = traceback.format_exception_only(Exception("projector"))
self.assertEqual(output, ["Exception: projector\n"])

exc = SyntaxError(NotImplemented)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And create a separate test ror those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"raise SyntaxError(NotImplemented)" exits REPL and IDLE subprocess

3 participants