[Python-checkins] bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851) (#17854)

Jason R. Coombs webhook-mailer at python.org
Mon Jan 6 07:34:14 EST 2020


https://github.com/python/cpython/commit/5ed9d60bc53e2eb0a88f07d5afe5299acdc0b216
commit: 5ed9d60bc53e2eb0a88f07d5afe5299acdc0b216
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Jason R. Coombs <jaraco at jaraco.com>
date: 2020-01-06T07:34:10-05:00
summary:

bpo-38907: In http.server script, restore binding to IPv4 on Windows. (GH-17851) (#17854)

(cherry picked from commit ee94bdb0598f9bc47d6a49e58fffc97aa617be96)

Co-authored-by: Jason R. Coombs <jaraco at jaraco.com>

Co-authored-by: Jason R. Coombs <jaraco at jaraco.com>

files:
A Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst
M Lib/http/server.py

diff --git a/Lib/http/server.py b/Lib/http/server.py
index b247675ec45e8..0fe44bdaa73fe 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -1280,4 +1280,16 @@ def test(HandlerClass=BaseHTTPRequestHandler,
     else:
         handler_class = partial(SimpleHTTPRequestHandler,
                                 directory=args.directory)
-    test(HandlerClass=handler_class, port=args.port, bind=args.bind)
+
+    # ensure dual-stack is not disabled; ref #38907
+    class DualStackServer(ThreadingHTTPServer):
+        def server_bind(self):
+            self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
+            return super().server_bind()
+
+    test(
+        HandlerClass=handler_class,
+        ServerClass=DualStackServer,
+        port=args.port,
+        bind=args.bind,
+    )
diff --git a/Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst b/Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst
new file mode 100644
index 0000000000000..a6e79f7809521
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-01-06-02-14-38.bpo-38907.F1RkCR.rst
@@ -0,0 +1 @@
+In http.server script, restore binding to IPv4 on Windows.
\ No newline at end of file



More information about the Python-checkins mailing list