Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Lib/test/test_ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
"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

Expand Down Expand Up @@ -80,7 +87,7 @@ def push(self, what):
super(DummyDTPHandler, self).push(what.encode(self.encoding))

def handle_error(self):
raise Exception
default_error_handler()


class DummyFTPHandler(asynchat.async_chat):
Expand Down Expand Up @@ -130,7 +137,7 @@ def found_terminator(self):
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')
Expand Down Expand Up @@ -308,7 +315,7 @@ def writable(self):
return 0

def handle_error(self):
raise Exception
default_error_handler()


if ssl is not None:
Expand Down Expand Up @@ -411,7 +418,7 @@ def recv(self, buffer_size):
raise

def handle_error(self):
raise Exception
default_error_handler()

def close(self):
if (isinstance(self.socket, ssl.SSLSocket) and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test_ftplib now silently ignores socket errors to prevent logging unhandled
threading exceptions. Patch by Victor Stinner.