]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 16 Jun 2025 07:05:26 +0000 (09:05 +0200)
committerGitHub <noreply@github.com>
Mon, 16 Jun 2025 07:05:26 +0000 (08:05 +0100)
(cherry picked from commit 2bd3895fcabb2dfdae5c0c72e60483e3d3267f0f)

Lib/http/server.py
Lib/logging/config.py
Lib/test/test_logging.py
Lib/xmlrpc/server.py
Misc/NEWS.d/next/Core_and_Builtins/2025-06-11-15-08-10.gh-issue-127319.OVGFSZ.rst [new file with mode: 0644]

index dda32644a28f9038426d17da4e94fd54c19ac336..10d18a9a75392977e1808b1b75556fef89d7f68f 100644 (file)
@@ -137,7 +137,7 @@ DEFAULT_ERROR_CONTENT_TYPE = "text/html;charset=utf-8"
 class HTTPServer(socketserver.TCPServer):
 
     allow_reuse_address = True    # Seems to make sense in testing environment
-    allow_reuse_port = True
+    allow_reuse_port = False
 
     def server_bind(self):
         """Override server_bind to store the server name."""
index c994349fd6eee54b3e2c8417c17633d8eac916a4..3d9aa00fa52d1166b3f6fe0ad8fb9511bc3e1057 100644 (file)
@@ -1018,7 +1018,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None):
         """
 
         allow_reuse_address = True
-        allow_reuse_port = True
+        allow_reuse_port = False
 
         def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
                      handler=None, ready=None, verify=None):
index 1e5adcc8db13f63ae6202b17228b88f10236b2e1..98ed154d8c652a4487edc060f78f4a0ed23c227e 100644 (file)
@@ -1036,7 +1036,7 @@ class TestTCPServer(ControlMixin, ThreadingTCPServer):
     """
 
     allow_reuse_address = True
-    allow_reuse_port = True
+    allow_reuse_port = False
 
     def __init__(self, addr, handler, poll_interval=0.5,
                  bind_and_activate=True):
index 90a356fbb8eae4575d053a75796f6958e7e682ee..8130c739af2fe889decb23c6af8667f5c7685826 100644 (file)
@@ -578,7 +578,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
     """
 
     allow_reuse_address = True
-    allow_reuse_port = True
+    allow_reuse_port = False
 
     # Warning: this is for debugging purposes only! Never set this to True in
     # production code, as will be sending out sensitive information (exception
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-11-15-08-10.gh-issue-127319.OVGFSZ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-11-15-08-10.gh-issue-127319.OVGFSZ.rst
new file mode 100644 (file)
index 0000000..d90153c
--- /dev/null
@@ -0,0 +1,3 @@
+Set the ``allow_reuse_port`` class variable to ``False`` on the XMLRPC,
+logging, and HTTP servers. This matches the behavior in prior Python
+releases, which is to not allow port reuse.