Message247452
In Python 3.4 on Windows 7, the code:
import socket
sock = socket.socket()
sock.bind(('127.0.0.1', 52384))
sock.listen(5)
sock.setblocking(False)
csock, addr = sock.accept()
Raised:
Traceback (most recent call last):
File "socket_bug_test.py", line 8, in <module>
csock, addr = sock.accept()
File "c:\bin\Python34\lib\socket.py", line 187, in accept
fd, addr = self._accept()
BlockingIOError: [WinError 10035] A non-blocking socket operation could not be completed immediately
In Python 3.5.0b3 on the same system, it is raising:
Traceback (most recent call last):
File "socket_bug_test.py", line 8, in <module>
csock, addr = sock.accept()
File "c:\bin\Python35\lib\socket.py", line 195, in accept
fd, addr = self._accept()
PermissionError: [WinError 5] Access is denied
This is a problem for other parts of the Standard Library. I hit it playing with asyncio, where in Lib\asyncio\selector_events.py the function BaseSelectorEventLoop._sock_accept() is prepared for an unready socket to raise BlockingIOError or InterruptedError, but does not catch the WinError:
try:
conn, address = sock.accept()
conn.setblocking(False)
except (BlockingIOError, InterruptedError):
self.add_reader(fd, self._sock_accept, fut, True, sock)
except Exception as exc:
fut.set_exception(exc)
else:
fut.set_result((conn, address))
There are other calls to accept in accept() in asyncio, that I haven't tested but also look adversely affected.
The older asyncore module looks to have a similar problem. In dispatcher.accept():
def accept(self):
# XXX can return either an address pair or None
try:
conn, addr = self.socket.accept()
except TypeError:
return None
except OSError as why:
if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
return None
else:
raise
else:
return conn, addr
The 'except OSError as why' will catch the WinError, but why.args[0] will be errno.EACCES = 13, permission denied, which is not equal to any of anticipated errors.
My system according to Python:
>>> import sys
>>> sys.version
'3.5.0b3 (default, Jul 5 2015, 07:00:46) [MSC v.1900 64 bit (AMD64)]'
>>> sys.getwindowsversion()
sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
That's Windows 7 Professional, 64-bit, with Service pack 1. It has an AND Phenom II X6 1055T Processor 2.8 GHz, and 8GB of memory. |
|
Date |
User |
Action |
Args |
2015-07-27 02:13:48 | bryangeneolson | set | recipients:
+ bryangeneolson, paul.moore, tim.golden, zach.ware, steve.dower |
2015-07-27 02:13:48 | bryangeneolson | set | messageid: <1437963228.18.0.486881534673.issue24732@psf.upfronthosting.co.za> |
2015-07-27 02:13:47 | bryangeneolson | link | issue24732 messages |
2015-07-27 02:13:45 | bryangeneolson | create | |
|