-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-34940: Fix the error handling in _check_for_legacy_statements() #9764
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
bpo-34940: Fix the error handling in _check_for_legacy_statements() #9764
Conversation
|
Objects/exceptions.c
Outdated
if (PyUnicode_Tailmatch(self->text, print_prefix, | ||
start, text_len, -1)) { | ||
|
||
Py_ssize_t match = PyUnicode_Tailmatch(self->text, print_prefix, |
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.
For symmetry with "exec" I suggest to move the match
variable declaration to the beginning of the function.
Objects/exceptions.c
Outdated
if (match == -1) { | ||
return -1; | ||
} | ||
if (match == 1) { |
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.
Since match
is a boolean here, I prefer to use just if (match)
instead of if (match == 1)
.
Objects/exceptions.c
Outdated
Py_XSETREF(self->msg, | ||
PyUnicode_FromString("Missing parentheses in call to 'exec'")); | ||
if (self->msg == NULL) { |
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.
Check for NULL before modifying self->msg
.
Thank you, @serhiy-storchaka, for reviewing my patches. |
https://bugs.python.org/issue34940