-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Unnecessary error-checking branch in lexer.c
.
#126469
Comments
There seems to be no problem. Are you willing to submit PR to fix it? I don't have time now (if you don't want to repair it, you can leave it to me, maybe it will be a little late. |
@rruuaanng yes , I can. |
I'm not sure it's a bug. This code was introduced in 74ea6b5. Obviously, at that time the check was required. The PyUnicode_READY() test was removed in f9c9354. So, it seems now _PyUnicode_ScanIdentifier() - can't fail. We can either (1) remove error check or (2) just keep that as-is, in case it might be required in future. I think we can go with (1). |
lexer.c
.
IMO, there's no need to remove that. We might want to make that raise an error in the future, and most compilers should (hopefully) optimize that away if it can't ever happen anyway. |
@ZeroIntensity So make it a comment or something else like __builtin_expect? |
|
Bug report
Bug description:
In file lexer.c we have
link
But for function _PyUnicode_ScanIdentifier in unicodeobject.c file
link
This function will never return a invalid valiable <0, so
will never be executed.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, macOS, Windows, Other
Linked PRs
lexer.c
#126473The text was updated successfully, but these errors were encountered: