cpython: 2156aa4050c7 (original) (raw)
Mercurial > cpython
changeset 103891:2156aa4050c7 3.6
Issue #26384: Merge from 3.5 [#26384]
Berker Peksag berker.peksag@gmail.com | |
---|---|
date | Sat, 17 Sep 2016 23:23:13 +0300 |
parents | 7b47c98f24da(current diff)78efbf499611(diff) |
children | 0d440fda8604 d0bab9fda568 |
files | Lib/socket.py Lib/test/test_socket.py Misc/NEWS |
diffstat | 3 files changed, 22 insertions(+), 1 deletions(-)[+] [-] Lib/socket.py 2 Lib/test/test_socket.py 19 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/socket.py +++ b/Lib/socket.py @@ -268,7 +268,7 @@ class socket(_socket.socket): raise _GiveupOnSendfile(err) # not a regular file try: fsize = os.fstat(fileno).st_size
except OSError:[](#l1.7)
except OSError as err:[](#l1.8) raise _GiveupOnSendfile(err) # not a regular file[](#l1.9) if not fsize:[](#l1.10) return 0 # empty file[](#l1.11)
--- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1485,6 +1485,25 @@ class GeneralModuleTests(unittest.TestCa self.assertEqual(s.family, 42424) self.assertEqual(s.type, 13331)
- @unittest.skipUnless(hasattr(os, 'sendfile'), 'test needs os.sendfile()')
- def test__sendfile_use_sendfile(self):
class File:[](#l2.9)
def __init__(self, fd):[](#l2.10)
self.fd = fd[](#l2.11)
def fileno(self):[](#l2.13)
return self.fd[](#l2.14)
with socket.socket() as sock:[](#l2.15)
fd = os.open(os.curdir, os.O_RDONLY)[](#l2.16)
os.close(fd)[](#l2.17)
with self.assertRaises(socket._GiveupOnSendfile):[](#l2.18)
sock._sendfile_use_sendfile(File(fd))[](#l2.19)
with self.assertRaises(OverflowError):[](#l2.20)
sock._sendfile_use_sendfile(File(2**1000))[](#l2.21)
with self.assertRaises(TypeError):[](#l2.22)
sock._sendfile_use_sendfile(File(None))[](#l2.23)
+ + @unittest.skipUnless(HAVE_SOCKET_CAN, 'SocketCan required for this test.') class BasicCANTest(unittest.TestCase):
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,8 @@ Core and Builtins Library ------- +- Fix UnboundLocalError in socket._sendfile_use_sendfile. +