Skip to content

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

Conversation

ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented Oct 9, 2018

@zhangyangyu
Copy link
Member

PyUnicode_Tailmatch fails when arguments are not string or they are failed to be readied. But in this case it seems not possible. Change it or add a comment are both okay to me.

if (PyUnicode_Tailmatch(self->text, print_prefix,
start, text_len, -1)) {

Py_ssize_t match = PyUnicode_Tailmatch(self->text, print_prefix,
Copy link
Member

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.

if (match == -1) {
return -1;
}
if (match == 1) {
Copy link
Member

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).

Py_XSETREF(self->msg,
PyUnicode_FromString("Missing parentheses in call to 'exec'"));
if (self->msg == NULL) {
Copy link
Member

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.

@ZackerySpytz
Copy link
Contributor Author

Thank you, @serhiy-storchaka, for reviewing my patches.

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.

5 participants