-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-123378: fix a crash in UnicodeError.__str__
#124935
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
Conversation
Unicode{Encode,Decode}Error.__str__
UnicodeError.__str__
5ca7f92
to
360c1a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thank you!
Lib/test/test_exceptions.py
Outdated
@@ -1336,6 +1337,26 @@ def test_unicode_errors_no_object(self): | |||
for klass in klasses: | |||
self.assertEqual(str(klass.__new__(klass)), "") | |||
|
|||
def test_unicode_error_str_gh_123378(self): | |||
for formatter, start, end, obj in product( | |||
(str, repr), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing repr() if we already test str() sounds redundant to me. Is it really worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you're right. I'll remove it.
Lib/test/test_exceptions.py
Outdated
@@ -1336,6 +1337,26 @@ def test_unicode_errors_no_object(self): | |||
for klass in klasses: | |||
self.assertEqual(str(klass.__new__(klass)), "") | |||
|
|||
def test_unicode_error_str_gh_123378(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the test is unclear to me, it just calls str(). Please add a comment to explain that you check that str() doesn't crash with a reference to the issue.
Lib/test/test_exceptions.py
Outdated
(str, repr), | ||
range(-5, 5), | ||
range(-5, 5), | ||
('', 'a', '123', '1234', '12345', 'abc123'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
('', 'a', '123', '1234', '12345', 'abc123'), | |
('', 'a', 'abc', 'abcde', 'abcdef'), |
(cherry picked from commit ba14dfa) Co-authored-by: Bénédikt Tran <[email protected]>
(cherry picked from commit ba14dfa) Co-authored-by: Bénédikt Tran <[email protected]>
GH-125098 is a backport of this pull request to the 3.12 branch. |
GH-125099 is a backport of this pull request to the 3.13 branch. |
…125098) gh-123378: fix a crash in `UnicodeError.__str__` (GH-124935) (cherry picked from commit ba14dfa) Co-authored-by: Bénédikt Tran <[email protected]>
…125099) gh-123378: fix a crash in `UnicodeError.__str__` (GH-124935) (cherry picked from commit ba14dfa) Co-authored-by: Bénédikt Tran <[email protected]>
cc @encukou @serhiy-storchaka @vstinner
start
values onPyUnicodeErrorObject
#123378