Commit 9fb061ba authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

Fix test_ftplib warning if IPv6 is not available (#1457)

DummyFTPServer now calls del_channel() on bind() error to prevent the
following warning in TestIPv6Environment.setUpClass():

Warning -- asyncore.socket_map was modified by test_ftplib
  Before: {}
  After:  {3: <test.test_ftplib.DummyFTPServer 127.0.0.1:0 at ...>}
parent 0f7f6766
...@@ -218,12 +218,18 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread): ...@@ -218,12 +218,18 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
threading.Thread.__init__(self) threading.Thread.__init__(self)
asyncore.dispatcher.__init__(self) asyncore.dispatcher.__init__(self)
self.create_socket(af, socket.SOCK_STREAM) self.create_socket(af, socket.SOCK_STREAM)
self.bind(address) try:
self.listen(5) self.bind(address)
self.active = False self.listen(5)
self.active_lock = threading.Lock() self.active = False
self.host, self.port = self.socket.getsockname()[:2] self.active_lock = threading.Lock()
self.handler_instance = None self.host, self.port = self.socket.getsockname()[:2]
self.handler_instance = None
except:
# unregister the server on bind() error,
# needed by TestIPv6Environment.setUpClass()
self.del_channel()
raise
def start(self): def start(self):
assert not self.active assert not self.active
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment