]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-131888: fix ResourceWarning in test_ftplib (GH-131889) (#132010)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 2 Apr 2025 12:46:40 +0000 (14:46 +0200)
committerGitHub <noreply@github.com>
Wed, 2 Apr 2025 12:46:40 +0000 (12:46 +0000)
gh-131888: fix ResourceWarning in test_ftplib (GH-131889)
(cherry picked from commit b0f77c4d250789fd1deaab4912919e2e6b89e583)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Lib/test/test_ftplib.py

index 4c4a4498d6fdd9582c0a417a085d754b66c3c06d..204a77d14f03a50ff7c349661e9541fc31ae690a 100644 (file)
@@ -80,7 +80,7 @@ class DummyDTPHandler(asynchat.async_chat):
         # (behaviour witnessed with test_data_connection)
         if not self.dtp_conn_closed:
             self.baseclass.push('226 transfer complete')
-            self.close()
+            self.shutdown()
             self.dtp_conn_closed = True
 
     def push(self, what):
@@ -94,6 +94,9 @@ class DummyDTPHandler(asynchat.async_chat):
     def handle_error(self):
         default_error_handler()
 
+    def shutdown(self):
+        self.close()
+
 
 class DummyFTPHandler(asynchat.async_chat):
 
@@ -226,7 +229,7 @@ class DummyFTPHandler(asynchat.async_chat):
 
     def cmd_quit(self, arg):
         self.push('221 quit ok')
-        self.close()
+        self.shutdown()
 
     def cmd_abor(self, arg):
         self.push('226 abor ok')
@@ -313,7 +316,7 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
         self.handler_instance = self.handler(conn, encoding=self.encoding)
 
     def handle_connect(self):
-        self.close()
+        self.shutdown()
     handle_read = handle_connect
 
     def writable(self):
@@ -425,12 +428,12 @@ if ssl is not None:
         def handle_error(self):
             default_error_handler()
 
-        def close(self):
+        def shutdown(self):
             if (isinstance(self.socket, ssl.SSLSocket) and
                     self.socket._sslobj is not None):
                 self._do_ssl_shutdown()
             else:
-                super(SSLConnection, self).close()
+                self.close()
 
 
     class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler):