mirror of
https://github.com/python/cpython.git
synced 2025-11-11 19:12:05 +00:00
[3.13] gh-126483: disable warnings filters mutation in concurrent test (GH-132694) (GH-135132)
The `test_ssl_in_multiple_threads` test failed because `test_check_hostname_idn()`
modified the global warnings filters via `warnings_helper.check_no_resource_warning()`.
Disable the warnings check in the multi-threaded test because `warnings_helper` isn't
thread-safe in 3.13 or earlier.
(cherry picked from commit 40c8be0008)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
* Fix for 3.13
---------
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
parent
70c7aad306
commit
ae2e7958f2
1 changed files with 30 additions and 12 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
import platform
|
import platform
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import functools
|
import functools
|
||||||
|
from contextlib import nullcontext
|
||||||
try:
|
try:
|
||||||
import ctypes
|
import ctypes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
@ -2879,7 +2880,10 @@ def test_ssl_in_multiple_threads(self):
|
||||||
self.test_alpn_protocols,
|
self.test_alpn_protocols,
|
||||||
self.test_getpeercert,
|
self.test_getpeercert,
|
||||||
self.test_crl_check,
|
self.test_crl_check,
|
||||||
self.test_check_hostname_idn,
|
functools.partial(
|
||||||
|
self.test_check_hostname_idn,
|
||||||
|
warnings_filters=False, # gh-126483
|
||||||
|
),
|
||||||
self.test_wrong_cert_tls12,
|
self.test_wrong_cert_tls12,
|
||||||
self.test_wrong_cert_tls13,
|
self.test_wrong_cert_tls13,
|
||||||
):
|
):
|
||||||
|
|
@ -3125,7 +3129,7 @@ def test_dual_rsa_ecc(self):
|
||||||
cipher = s.cipher()[0].split('-')
|
cipher = s.cipher()[0].split('-')
|
||||||
self.assertTrue(cipher[:2], ('ECDHE', 'ECDSA'))
|
self.assertTrue(cipher[:2], ('ECDHE', 'ECDSA'))
|
||||||
|
|
||||||
def test_check_hostname_idn(self):
|
def test_check_hostname_idn(self, warnings_filters=True):
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
sys.stdout.write("\n")
|
sys.stdout.write("\n")
|
||||||
|
|
||||||
|
|
@ -3180,16 +3184,30 @@ def test_check_hostname_idn(self):
|
||||||
server_hostname="python.example.org") as s:
|
server_hostname="python.example.org") as s:
|
||||||
with self.assertRaises(ssl.CertificateError):
|
with self.assertRaises(ssl.CertificateError):
|
||||||
s.connect((HOST, server.port))
|
s.connect((HOST, server.port))
|
||||||
with ThreadedEchoServer(context=server_context, chatty=True) as server:
|
with (
|
||||||
with warnings_helper.check_no_resource_warning(self):
|
ThreadedEchoServer(context=server_context, chatty=True) as server,
|
||||||
with self.assertRaises(UnicodeError):
|
(
|
||||||
context.wrap_socket(socket.socket(),
|
warnings_helper.check_no_resource_warning(self)
|
||||||
server_hostname='.pythontest.net')
|
if warnings_filters
|
||||||
with ThreadedEchoServer(context=server_context, chatty=True) as server:
|
else nullcontext()
|
||||||
with warnings_helper.check_no_resource_warning(self):
|
),
|
||||||
with self.assertRaises(UnicodeDecodeError):
|
self.assertRaises(UnicodeError),
|
||||||
context.wrap_socket(socket.socket(),
|
):
|
||||||
server_hostname=b'k\xf6nig.idn.pythontest.net')
|
context.wrap_socket(socket.socket(), server_hostname='.pythontest.net')
|
||||||
|
|
||||||
|
with (
|
||||||
|
ThreadedEchoServer(context=server_context, chatty=True) as server,
|
||||||
|
(
|
||||||
|
warnings_helper.check_no_resource_warning(self)
|
||||||
|
if warnings_filters
|
||||||
|
else nullcontext()
|
||||||
|
),
|
||||||
|
self.assertRaises(UnicodeDecodeError),
|
||||||
|
):
|
||||||
|
context.wrap_socket(
|
||||||
|
socket.socket(),
|
||||||
|
server_hostname=b'k\xf6nig.idn.pythontest.net',
|
||||||
|
)
|
||||||
|
|
||||||
def test_wrong_cert_tls12(self):
|
def test_wrong_cert_tls12(self):
|
||||||
"""Connecting when the server rejects the client's certificate
|
"""Connecting when the server rejects the client's certificate
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue