File tree Expand file tree Collapse file tree 5 files changed +42
-4
lines changed Expand file tree Collapse file tree 5 files changed +42
-4
lines changed Original file line number Diff line number Diff line change
1
+ Upgrade truststore to 0.10.1
Original file line number Diff line number Diff line change 7
7
8
8
# Detect Python runtimes which don't implement SSLObject.get_unverified_chain() API
9
9
# This API only became public in Python 3.13 but was available in CPython and PyPy since 3.10.
10
- if _sys .version_info < (3 , 13 ):
10
+ if _sys .version_info < (3 , 13 ) and _sys . implementation . name not in ( "cpython" , "pypy" ) :
11
11
try :
12
12
import ssl as _ssl
13
13
except ImportError :
33
33
del _api , _sys # type: ignore[name-defined] # noqa: F821
34
34
35
35
__all__ = ["SSLContext" , "inject_into_ssl" , "extract_from_ssl" ]
36
- __version__ = "0.10.0 "
36
+ __version__ = "0.10.1 "
Original file line number Diff line number Diff line change 5
5
import sys
6
6
import typing
7
7
8
- import _ssl # type: ignore[import-not-found]
8
+ import _ssl
9
9
10
10
from ._ssl_constants import (
11
11
_original_SSLContext ,
@@ -43,6 +43,23 @@ def inject_into_ssl() -> None:
43
43
except ImportError :
44
44
pass
45
45
46
+ # requests starting with 2.32.0 added a preloaded SSL context to improve concurrent performance;
47
+ # this unfortunately leads to a RecursionError, which can be avoided by patching the preloaded SSL context with
48
+ # the truststore patched instance
49
+ # also see https://github.com/psf/requests/pull/6667
50
+ try :
51
+ from pip ._vendor .requests import adapters as requests_adapters
52
+
53
+ preloaded_context = getattr (requests_adapters , "_preloaded_ssl_context" , None )
54
+ if preloaded_context is not None :
55
+ setattr (
56
+ requests_adapters ,
57
+ "_preloaded_ssl_context" ,
58
+ SSLContext (ssl .PROTOCOL_TLS_CLIENT ),
59
+ )
60
+ except ImportError :
61
+ pass
62
+
46
63
47
64
def extract_from_ssl () -> None :
48
65
"""Restores the :class:`ssl.SSLContext` class to its original state"""
Original file line number Diff line number Diff line change @@ -15,4 +15,4 @@ rich==13.9.4
15
15
resolvelib==1.0.1
16
16
setuptools==70.3.0
17
17
tomli==2.2.1
18
- truststore==0.10.0
18
+ truststore==0.10.1
Original file line number Diff line number Diff line change
1
+ diff --git a/src/pip/_vendor/truststore/_api.py b/src/pip/_vendor/truststore/_api.py
2
+ index 47b7a63ab..d09d3096f 100644
3
+ --- a/src/pip/_vendor/truststore/_api.py
4
+ +++ b/src/pip/_vendor/truststore/_api.py
5
+ @@ -48,12 +48,12 @@ def inject_into_ssl() -> None:
6
+ # the truststore patched instance
7
+ # also see https://github.com/psf/requests/pull/6667
8
+ try:
9
+ - import requests.adapters
10
+ + from pip._vendor.requests import adapters as requests_adapters
11
+
12
+ - preloaded_context = getattr(requests.adapters, "_preloaded_ssl_context", None)
13
+ + preloaded_context = getattr(requests_adapters, "_preloaded_ssl_context", None)
14
+ if preloaded_context is not None:
15
+ setattr(
16
+ - requests.adapters,
17
+ + requests_adapters,
18
+ "_preloaded_ssl_context",
19
+ SSLContext(ssl.PROTOCOL_TLS_CLIENT),
20
+ )
You can’t perform that action at this time.
0 commit comments