|
31 | 31 | import platform
|
32 | 32 | import sysconfig
|
33 | 33 | import functools
|
| 34 | +from contextlib import nullcontext |
34 | 35 | try:
|
35 | 36 | import ctypes
|
36 | 37 | except ImportError:
|
@@ -2879,7 +2880,10 @@ def test_ssl_in_multiple_threads(self):
|
2879 | 2880 | self.test_alpn_protocols,
|
2880 | 2881 | self.test_getpeercert,
|
2881 | 2882 | self.test_crl_check,
|
2882 |
| - self.test_check_hostname_idn, |
| 2883 | + functools.partial( |
| 2884 | + self.test_check_hostname_idn, |
| 2885 | + warnings_filters=False, # gh-126483 |
| 2886 | + ), |
2883 | 2887 | self.test_wrong_cert_tls12,
|
2884 | 2888 | self.test_wrong_cert_tls13,
|
2885 | 2889 | ):
|
@@ -3125,7 +3129,7 @@ def test_dual_rsa_ecc(self):
|
3125 | 3129 | cipher = s.cipher()[0].split('-')
|
3126 | 3130 | self.assertTrue(cipher[:2], ('ECDHE', 'ECDSA'))
|
3127 | 3131 |
|
3128 |
| - def test_check_hostname_idn(self): |
| 3132 | + def test_check_hostname_idn(self, warnings_filters=True): |
3129 | 3133 | if support.verbose:
|
3130 | 3134 | sys.stdout.write("\n")
|
3131 | 3135 |
|
@@ -3180,16 +3184,30 @@ def test_check_hostname_idn(self):
|
3180 | 3184 | server_hostname="python.example.org") as s:
|
3181 | 3185 | with self.assertRaises(ssl.CertificateError):
|
3182 | 3186 | s.connect((HOST, server.port))
|
3183 |
| - with ThreadedEchoServer(context=server_context, chatty=True) as server: |
3184 |
| - with warnings_helper.check_no_resource_warning(self): |
3185 |
| - with self.assertRaises(UnicodeError): |
3186 |
| - context.wrap_socket(socket.socket(), |
3187 |
| - server_hostname='.pythontest.net') |
3188 |
| - with ThreadedEchoServer(context=server_context, chatty=True) as server: |
3189 |
| - with warnings_helper.check_no_resource_warning(self): |
3190 |
| - with self.assertRaises(UnicodeDecodeError): |
3191 |
| - context.wrap_socket(socket.socket(), |
3192 |
| - server_hostname=b'k\xf6nig.idn.pythontest.net') |
| 3187 | + with ( |
| 3188 | + ThreadedEchoServer(context=server_context, chatty=True) as server, |
| 3189 | + ( |
| 3190 | + warnings_helper.check_no_resource_warning(self) |
| 3191 | + if warnings_filters |
| 3192 | + else nullcontext() |
| 3193 | + ), |
| 3194 | + self.assertRaises(UnicodeError), |
| 3195 | + ): |
| 3196 | + context.wrap_socket(socket.socket(), server_hostname='.pythontest.net') |
| 3197 | + |
| 3198 | + with ( |
| 3199 | + ThreadedEchoServer(context=server_context, chatty=True) as server, |
| 3200 | + ( |
| 3201 | + warnings_helper.check_no_resource_warning(self) |
| 3202 | + if warnings_filters |
| 3203 | + else nullcontext() |
| 3204 | + ), |
| 3205 | + self.assertRaises(UnicodeDecodeError), |
| 3206 | + ): |
| 3207 | + context.wrap_socket( |
| 3208 | + socket.socket(), |
| 3209 | + server_hostname=b'k\xf6nig.idn.pythontest.net', |
| 3210 | + ) |
3193 | 3211 |
|
3194 | 3212 | def test_wrong_cert_tls12(self):
|
3195 | 3213 | """Connecting when the server rejects the client's certificate
|
|
0 commit comments