|
56 | 56 | "type=file;perm=r;unique==SGP2; file \xAE non-ascii char\r\n")
|
57 | 57 |
|
58 | 58 |
|
| 59 | +def default_error_handler(): |
| 60 | + # bpo-44359: Silently ignore socket errors. Such errors occur when a client |
| 61 | + # socket is closed, in TestFTPClass.tearDown() and makepasv() tests, and |
| 62 | + # the server gets an error on its side. |
| 63 | + pass |
| 64 | + |
| 65 | + |
59 | 66 | class DummyDTPHandler(asynchat.async_chat):
|
60 | 67 | dtp_conn_closed = False
|
61 | 68 |
|
@@ -87,7 +94,7 @@ def push(self, what):
|
87 | 94 | super(DummyDTPHandler, self).push(what.encode(self.encoding))
|
88 | 95 |
|
89 | 96 | def handle_error(self):
|
90 |
| - raise Exception |
| 97 | + default_error_handler() |
91 | 98 |
|
92 | 99 |
|
93 | 100 | class DummyFTPHandler(asynchat.async_chat):
|
@@ -137,7 +144,7 @@ def found_terminator(self):
|
137 | 144 | self.push('550 command "%s" not understood.' %cmd)
|
138 | 145 |
|
139 | 146 | def handle_error(self):
|
140 |
| - raise Exception |
| 147 | + default_error_handler() |
141 | 148 |
|
142 | 149 | def push(self, data):
|
143 | 150 | asynchat.async_chat.push(self, data.encode(self.encoding) + b'\r\n')
|
@@ -315,7 +322,7 @@ def writable(self):
|
315 | 322 | return 0
|
316 | 323 |
|
317 | 324 | def handle_error(self):
|
318 |
| - raise Exception |
| 325 | + default_error_handler() |
319 | 326 |
|
320 | 327 |
|
321 | 328 | if ssl is not None:
|
@@ -418,7 +425,7 @@ def recv(self, buffer_size):
|
418 | 425 | raise
|
419 | 426 |
|
420 | 427 | def handle_error(self):
|
421 |
| - raise Exception |
| 428 | + default_error_handler() |
422 | 429 |
|
423 | 430 | def close(self):
|
424 | 431 | if (isinstance(self.socket, ssl.SSLSocket) and
|
|
0 commit comments