From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:58:46 +0000 (-0700) Subject: [3.11] gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-11040... X-Git-Tag: v3.11.7~247 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cacea7a27260f56f6a29f0d7d37878c569d59cfb;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-110401) (#110406) gh-110391: socket NetworkConnectionAttributesTest always declare cli (GH-110401) NetworkConnectionAttributesTest of test_socket now always declare the 'cli' attribute, so clientTearDown() cannot fail with AttributeError. (cherry picked from commit e37d4557c3de0476e76ca4b8a1cc8d2566b86c79) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index af0d2a4e6f63..190efb416ba3 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -5239,6 +5239,7 @@ class NetworkConnectionNoServer(unittest.TestCase): class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): + cli = None def __init__(self, methodName='runTest'): SocketTCPTest.__init__(self, methodName=methodName) @@ -5248,7 +5249,8 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest): self.source_port = socket_helper.find_unused_port() def clientTearDown(self): - self.cli.close() + if self.cli is not None: + self.cli.close() self.cli = None ThreadableTest.clientTearDown(self)