diff options
author | Victor Stinner <vstinner@python.org> | 2022-02-02 01:47:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-02 01:47:40 (GMT) |
commit | 0611eafc709cbe8a2a0bdde082d25df0c5034de7 (patch) | |
tree | 8e01590243696b2b8e6908493d22d946bda53c28 /Lib | |
parent | 53c78080573b3bae4c4e782b9f47dce48aac9688 (diff) | |
download | cpython-0611eafc709cbe8a2a0bdde082d25df0c5034de7.zip cpython-0611eafc709cbe8a2a0bdde082d25df0c5034de7.tar.gz cpython-0611eafc709cbe8a2a0bdde082d25df0c5034de7.tar.bz2 |
bpo-44359: Fix test_ftplib unhandled thread exceptions (GH-31069)
test_ftplib now silently ignores socket errors to prevent logging
unhandled threading exceptions.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_ftplib.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 56e3d8a..2f5cc06 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -56,6 +56,13 @@ MLSD_DATA = ("type=cdir;perm=el;unique==keVO1+ZF4; test\r\n" "type=file;perm=r;unique==SGP2; file \xAE non-ascii char\r\n") +def default_error_handler(): + # bpo-44359: Silently ignore socket errors. Such errors occur when a client + # socket is closed, in TestFTPClass.tearDown() and makepasv() tests, and + # the server gets an error on its side. + pass + + class DummyDTPHandler(asynchat.async_chat): dtp_conn_closed = False @@ -87,7 +94,7 @@ class DummyDTPHandler(asynchat.async_chat): super(DummyDTPHandler, self).push(what.encode(self.encoding)) def handle_error(self): - raise Exception + default_error_handler() class DummyFTPHandler(asynchat.async_chat): @@ -137,7 +144,7 @@ class DummyFTPHandler(asynchat.async_chat): self.push('550 command "%s" not understood.' %cmd) def handle_error(self): - raise Exception + default_error_handler() def push(self, data): asynchat.async_chat.push(self, data.encode(self.encoding) + b'\r\n') @@ -315,7 +322,7 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread): return 0 def handle_error(self): - raise Exception + default_error_handler() if ssl is not None: @@ -418,7 +425,7 @@ if ssl is not None: raise def handle_error(self): - raise Exception + default_error_handler() def close(self): if (isinstance(self.socket, ssl.SSLSocket) and |