-
-
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
UnboundLocalError in socket._sendfile_use_sendfile #70572
Comments
I noticed this while working on bpo-16915: Traceback (most recent call last):
...
File "/home/berker/projects/cpython/default/Lib/socket.py", line 262, in _sendfile_use_sendfile
raise _GiveupOnSendfile(err) # not a regular file
UnboundLocalError: local variable 'err' referenced before assignment Here's a patch. |
This issue can be tested without moking os.fstat(): class F:
def fileno(self):
return fd
with socket.socket() as sock:
fd = os.open(os.curdir, os.O_RDONLY)
os.close(fd)
self.assertRaises(socket._GiveupOnSendfile,
sock._sendfile_use_sendfile, F()) os.fstat() can raise not only OSError. It may be worth to test also with fd = 2**1000 and fd = None. |
Thanks, Serhiy. Here's an updated patch. |
LGTM. |
New changeset 78efbf499611 by Berker Peksag in branch '3.5': New changeset 2156aa4050c7 by Berker Peksag in branch '3.6': New changeset 0d440fda8604 by Berker Peksag in branch 'default': |
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: