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
_ctypes\cfield.c identical subexpressions in Z_set #70032
Comments
I found this while writing up a separate bug (CPython doesn't use static analysis!). In _ctypes/cfield.c, Z_set has a bug of some sort: if (PyLong_Check(value) || PyLong_Check(value)) { See: https://hg.python.org/cpython/file/tip/Modules/_ctypes/cfield.c#l1378 ...which has been there for at least 5 years: https://hg.python.org/cpython/rev/cab14be0ada1 I'm not sure what the original programmer meant - it's been around forever & I don't know what was there before it - but PyLong_Check(value) is evaluated twice. Which doesn't really make sense. Compiling with /analyze found this quite easily: c:\pythondev\repo\modules\_ctypes\cfield.c(1378): warning C6287: Redundant code: the left and right sub-expressions are identical. There's a similar issue in P_set, at line 1486. |
Looks like a result of searching and replacing PyInt with PyLong - the diff can be found here, if anyone cares. https://hg.python.org/cpython-fullhistory/rev/f324631462a2. Oddly, there was _another, older_ revision that fixed this correctly: https://hg.python.org/cpython-fullhistory/rev/003d35215ef2 - looks like there was a bad merge somewhere along the line. |
Sorry, my mistake, I was looking at z_set instead of Z_set. The earlier fix had left Z_set out for some reason. Anyway, just some historical interest anyway. |
New changeset 26859a7e385c by Martin Panter in branch '3.5': New changeset 9be59ad8af80 by Martin Panter in branch 'default': |
History is good for understanding how things became the way they are. :) Thanks Alexander and Random! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: