Open qqwqqw689 opened 1 week ago
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 74ea6b5a75. Obviously, at that time the check was required. The PyUnicode_READY() test was removed in f9c9354a7a. 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).
CC @methane as author of f9c9354a7a
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?
__builtin_expect
could work, yeah.
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