-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-31592: Fix an assertion failure in Python/ast.c in case of a bad unicodedata.normalize() #3767
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
Merged
serhiy-storchaka
merged 7 commits into
python:master
from
orenmn:bpo31592-fix-assert-fail
Sep 30, 2017
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ff1fe99
init commit
orenmn fb73e9f
fix another bug in the C code
orenmn 29f4604
use _PyList_ITEMS()
orenmn c29d5c0
revert the change. of course, this is a tuple, not a list.
orenmn cdaead9
completely remove c_normalize_args
orenmn 56c7ead
use _Py_IDENTIFIER()
orenmn 4e0a149
Update 2017-09-26-16-05-04.bpo-31592.IFBZj9.rst
serhiy-storchaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
revert the change. of course, this is a tuple, not a list.
- Loading branch information
commit c29d5c011a55d4a1b74e0ddcf03d89e4f112e09b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't use
c->c_normalize_args
. Use just a 2-element C array.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.
All right.
Would you mind to mention why this is better?
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 problem is with reusing the same tuple for passing arguments. If the fake
normalize()
save the reference to the tuple, it will see that an immutable tuple is mutated. It should be implemented in C, I can't reproduce the problem with Python code.Just allocate a 2-element array on the stack, fill it with arguments, and pass it to the function. This will significantly simplify the code too.
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.
Or just revert you last change, I'll create a separate PR. These bugs are related to the same function, but can be fixed separately.
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.
I understand that we must conceal the tuple
c->c_normalize_args
from the user.Doesn't my patch conceal it? I passed only the tuple items array to
_PyObject_FastCall()
, so even it doesn't have access to the tuple.for example,
_PyObject_FastCall()
might eventually cause callingfunction_code_fastcall()
, which would copy the args C array intof_localsplus
, or it might call_PyStack_AsTuple()
, which would copy the args C array into a new tuple.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.
Or is my fix bad because it uses the internal structure of
tuple
?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.
Yes, your patch conceal it. But using
c->c_normalize_args
as a buffer is suboptimal. You don't need a heap allocation, and the code would be simpler if use a stack variable.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.
cool, thanks for the explanation :)