Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2775d85

Browse files
committed
merge 3.4 (#25471)
2 parents 0a467d1 + d9dbf49 commit 2775d85

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/socket.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ def accept(self):
193193
For IP sockets, the address info is a pair (hostaddr, port).
194194
"""
195195
fd, addr = self._accept()
196-
sock = socket(self.family, self.type, self.proto, fileno=fd)
196+
# If our type has the SOCK_NONBLOCK flag, we shouldn't pass it onto the
197+
# new socket. We do not currently allow passing SOCK_NONBLOCK to
198+
# accept4, so the returned socket is always blocking.
199+
type = self.type & ~globals().get("SOCK_NONBLOCK", 0)
200+
sock = socket(self.family, type, self.proto, fileno=fd)
197201
# Issue #7995: if no default timeout is set and the listening
198202
# socket had a (non-zero) timeout, force the new socket in blocking
199203
# mode to override platform-specific socket flags inheritance.

Lib/test/test_socket.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3866,6 +3866,7 @@ def testAccept(self):
38663866
read, write, err = select.select([self.serv], [], [])
38673867
if self.serv in read:
38683868
conn, addr = self.serv.accept()
3869+
self.assertIsNone(conn.gettimeout())
38693870
conn.close()
38703871
else:
38713872
self.fail("Error trying to do accept after select.")

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ Library
189189
- Issue #24881: Fixed setting binary mode in Python implementation of FileIO
190190
on Windows and Cygwin. Patch from Akira Li.
191191

192+
- Issue #25471: Sockets returned from accept() shouldn't appear to be
193+
nonblocking.
194+
192195
- Issue #25319: When threading.Event is reinitialized, the underlying condition
193196
should use a regular lock rather than a recursive lock.
194197

0 commit comments

Comments
 (0)