[Python-checkins] Fix host in address of socket.create_server example. (GH-17706)

Karthikeyan Singaravelan webhook-mailer at python.org
Sat Jan 11 00:16:38 EST 2020

commit: 43682f1e39a3c61f0e8a638b887bcdcbfef766c5
branch: master
author: Karthikeyan Singaravelan <tir.karthi at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-01-11T10:46:30+05:30

Fix host in address of socket.create_server example. (GH-17706)

Host as None in address raises TypeError since it should be string, bytes or bytearray.

M Lib/socket.py

diff --git a/Lib/socket.py b/Lib/socket.py
index 374f1124bf7e8..cafa573a30c05 100755
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -878,7 +878,7 @@ def create_server(address, *, family=AF_INET, backlog=None, reuse_port=False,
     connections. When false it will explicitly disable this option on
     platforms that enable it by default (e.g. Linux).
-    >>> with create_server((None, 8000)) as server:
+    >>> with create_server(('', 8000)) as server:
     ...     while True:
     ...         conn, addr = server.accept()
     ...         # handle new connection

More information about the Python-checkins mailing list