Skip to content

Commit b0f77c4

Browse files
authored
gh-131888: fix ResourceWarning in test_ftplib (#131889)
1 parent ab2a3dd commit b0f77c4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: Lib/test/test_ftplib.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def handle_close(self):
8181
# (behaviour witnessed with test_data_connection)
8282
if not self.dtp_conn_closed:
8383
self.baseclass.push('226 transfer complete')
84-
self.close()
84+
self.shutdown()
8585
self.dtp_conn_closed = True
8686

8787
def push(self, what):
@@ -95,6 +95,9 @@ def push(self, what):
9595
def handle_error(self):
9696
default_error_handler()
9797

98+
def shutdown(self):
99+
self.close()
100+
98101

99102
class DummyFTPHandler(asynchat.async_chat):
100103

@@ -227,7 +230,7 @@ def cmd_type(self, arg):
227230

228231
def cmd_quit(self, arg):
229232
self.push('221 quit ok')
230-
self.close()
233+
self.shutdown()
231234

232235
def cmd_abor(self, arg):
233236
self.push('226 abor ok')
@@ -314,7 +317,7 @@ def handle_accepted(self, conn, addr):
314317
self.handler_instance = self.handler(conn, encoding=self.encoding)
315318

316319
def handle_connect(self):
317-
self.close()
320+
self.shutdown()
318321
handle_read = handle_connect
319322

320323
def writable(self):
@@ -426,12 +429,12 @@ def recv(self, buffer_size):
426429
def handle_error(self):
427430
default_error_handler()
428431

429-
def close(self):
432+
def shutdown(self):
430433
if (isinstance(self.socket, ssl.SSLSocket) and
431434
self.socket._sslobj is not None):
432435
self._do_ssl_shutdown()
433436
else:
434-
super(SSLConnection, self).close()
437+
self.close()
435438

436439

437440
class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler):

0 commit comments

Comments
 (0)