-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-125889: Fix bounds check of hi argument in bisect_left|right functions #125915
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
|
Can you add a test? |
|
I'm editing it, this may take a while, please excuse me. |
|
For the two solutions mentioned by I chose the latter because almost all test functions in the test assume that when hi is a negative number, there will be a default processing. But I don't want to refactor this test on a large scale, so I chose the latter, and in the test, it mainly judges that when its hi is a negative number, it can automatically handle it. Is negative and it is not negative 1, it can be negative infinity. |
|
I see a modification to If someone somehow winds up running the python code in Lib/bisect.py, would it still have the bug? |
|
Maybe not. You can read the test I added.It described that under normal use, when the hi parameter is negative, there will be no abnormality. I'm not sure if this is what you expected. Edit In fact, the c file I changed corresponds to the implementation in python. Generally, python calls the c function. |
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.
In fact, the c file I changed corresponds to the implementation in python. Generally, python calls the c function.
This is incorrect. The C implementation is used if it is available. I think we should first discuss more on whether negative indices should be supported at all.
Currently hi == -1 means for the C implementation "not given" but we should decide first whether hi < 0 means "count from the end". And we should synchronize both the Python and the C implementation so that they consider hi < 0 the same way.
Misc/NEWS.d/next/Library/2024-10-24-15-21-03.gh-issue-125889.P9MXpN.rst
Outdated
Show resolved
Hide resolved
|
Oh, forgive me, the description seems to be a little failed. I want to say c implementation, but what it mentions is py implementation. I will continue to change it later. |
|
FWIW, the |
|
Therefore, there are two points of focus on the current discussion.
|
|
I will close this RP, maybe we need to wait until that unified proposal before moving forward, then we can reopen it. Thank you for your attention to this. |
Uh oh!
There was an error while loading. Please reload this page.