-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Inconsistent code found by static analyzers at base_events.py #132307
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
Comments
I'm pretty sure we can just remove the |
But, should we really? Is there any indication that something does not work? Or that this check is slow? |
It's just dead code. That check can never fail, because if it was |
I think it is fine to remove it although it doesn't matter much. |
Greetings! I've been analyzing Cpython with Svace static analyzer. It has found a code inconsitency issue at the
asyncio
library in the following method:cpython/Lib/asyncio/base_events.py
Lines 1653 to 1681 in 7ebbd27
The problem is a redundant comparison with a
None
value for referencesock
here:cpython/Lib/asyncio/base_events.py
Lines 1669 to 1670 in 7ebbd27
which has already been dereferenced before:
cpython/Lib/asyncio/base_events.py
Lines 1658 to 1659 in 7ebbd27
According to the documentation, the
sock
input parameter is a preexisting object returned from thesocket.accept()
function. So it shouldn't beNone
Proposed solution
I believe it is advisable to either move the null check for
sock
to the beginning of the function, or remove it. I'm not sure which of these options would be more in line with the regulations. After I get a response, I might be able to create a pull request.Linked PRs
asyncio/base_events.py
#132324The text was updated successfully, but these errors were encountered: