Skip to content

[Skip Issue] tokenizer.c: Replace unneeded PyUnicode_READY() with an assertion#9114

Merged
serhiy-storchaka merged 2 commits into
python:masterfrom
ZackerySpytz:verify_identifier-ready
Sep 10, 2018
Merged

[Skip Issue] tokenizer.c: Replace unneeded PyUnicode_READY() with an assertion#9114
serhiy-storchaka merged 2 commits into
python:masterfrom
ZackerySpytz:verify_identifier-ready

Conversation

@ZackerySpytz
Copy link
Copy Markdown
Contributor

In verify_identifier(), PyUnicode_READY(s) == -1 would never occur
(PyUnicode_DecodeUTF8() always returns a ready string on success).
Also, if PyUnicode_READY(s) == -1 did actually occur here, there would
be a reference leak.

In verify_identifier(), PyUnicode_READY(s) == -1 would never occur
(PyUnicode_DecodeUTF8() always returns a ready string on success).
Also, if PyUnicode_READY(s) == -1 did actually occur here, there would
be a reference leak.
Comment thread Parser/tokenizer.c Outdated
}
return 0;
}
assert(PyUnicode_IS_READY(s));
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.

This assert is not needed sincePyUnicode_IsIdentifier() calls PyUnicode_READY().

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.

True. I added this assertion mainly because new_identifier() in ast.c has it immediately after PyUnicode_DecodeUTF8().

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.

4 participants