]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1531963: Make SocketServer.TCPServer's server_address always be equal to calling...
authorCollin Winter <collinw@gmail.com>
Sat, 10 Mar 2007 02:51:26 +0000 (02:51 +0000)
committerCollin Winter <collinw@gmail.com>
Sat, 10 Mar 2007 02:51:26 +0000 (02:51 +0000)
Will backport.

Lib/SocketServer.py
Lib/test/test_socketserver.py
Misc/NEWS

index 3a74c444ba182ed01edf50bbe4a78c7108906bf3..7d9b9a536a94179b591c54e2c1080c974b5d8ae2 100644 (file)
@@ -339,6 +339,7 @@ class TCPServer(BaseServer):
         if self.allow_reuse_address:
             self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         self.socket.bind(self.server_address)
+        self.server_address = self.socket.getsockname()
 
     def server_activate(self):
         """Called by constructor to activate the server.
index e4cbb2b58888b4c8c7af7ef0d310d18fb497b280..62321757068dcefb3d9f407f8d8b8faac950a390 100644 (file)
@@ -84,6 +84,7 @@ class ServerThread(threading.Thread):
         addr = getattr(svr, 'server_address')
         if addr:
             self.__addr = addr
+            assert self.__addr == svr.socket.getsockname()
         if verbose: print "thread: serving three times"
         svr.serve_a_few()
         if verbose: print "thread: done"
index ef5403928a29eae532363f88634fefcd4b01d644..262972c97cd7cd7eda48673fc3d1a0d211ae699b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -156,6 +156,9 @@ Core and builtins
 Library
 -------
 
+- Bug #1531963: Make SocketServer.TCPServer's server_address always
+  be equal to calling getsockname() on the server's socket.
+
 - Bug #1651235: When a tuple was passed to a ctypes function call,
   Python would crash instead of raising an error.