summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/socket.rst2
-rw-r--r--Lib/socket.py7
-rw-r--r--Misc/NEWS.d/next/Library/2019-04-09-04-08-46.bpo-17561.hOhVnh.rst1
3 files changed, 7 insertions, 3 deletions
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index b4a07bd..62c8347 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -595,7 +595,7 @@ The following functions all create :ref:`socket objects <socket-objects>`.
.. versionchanged:: 3.2
*source_address* was added.
-.. function:: create_server(address, *, family=AF_INET, backlog=0, reuse_port=False, dualstack_ipv6=False)
+.. function:: create_server(address, *, family=AF_INET, backlog=None, reuse_port=False, dualstack_ipv6=False)
Convenience function which creates a TCP socket bound to *address* (a 2-tuple
``(host, port)``) and return the socket object.
diff --git a/Lib/socket.py b/Lib/socket.py
index 2e51cd1..0dd8ec7 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -745,7 +745,7 @@ def has_dualstack_ipv6():
return False
-def create_server(address, *, family=AF_INET, backlog=0, reuse_port=False,
+def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False,
dualstack_ipv6=False):
"""Convenience function which creates a SOCK_STREAM type socket
bound to *address* (a 2-tuple (host, port)) and return the socket
@@ -804,7 +804,10 @@ def create_server(address, *, family=AF_INET, backlog=0, reuse_port=False,
msg = '%s (while attempting to bind on address %r)' % \
(err.strerror, address)
raise error(err.errno, msg) from None
- sock.listen(backlog)
+ if backlog is None:
+ sock.listen()
+ else:
+ sock.listen(backlog)
return sock
except error:
sock.close()
diff --git a/Misc/NEWS.d/next/Library/2019-04-09-04-08-46.bpo-17561.hOhVnh.rst b/Misc/NEWS.d/next/Library/2019-04-09-04-08-46.bpo-17561.hOhVnh.rst
new file mode 100644
index 0000000..e281c22
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-04-09-04-08-46.bpo-17561.hOhVnh.rst
@@ -0,0 +1 @@
+Set backlog=None as the default for socket.create_server.