Skip to content

Commit d52011f

Browse files
authored
Upgrade truststore to 0.10.4 (#13544)
1 parent 36f9f86 commit d52011f

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

news/truststore.vendor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade truststore to 0.10.3
1+
Upgrade truststore to 0.10.4

src/pip/_vendor/truststore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
del _api, _sys # type: ignore[name-defined] # noqa: F821
3434

3535
__all__ = ["SSLContext", "inject_into_ssl", "extract_from_ssl"]
36-
__version__ = "0.10.3"
36+
__version__ = "0.10.4"

src/pip/_vendor/truststore/_api.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import contextlib
12
import os
23
import platform
34
import socket
45
import ssl
56
import sys
7+
import threading
68
import typing
79

810
import _ssl
@@ -84,6 +86,7 @@ def __class__(self) -> type:
8486

8587
def __init__(self, protocol: int = None) -> None: # type: ignore[assignment]
8688
self._ctx = _original_SSLContext(protocol)
89+
self._ctx_lock = threading.Lock()
8790

8891
class TruststoreSSLObject(ssl.SSLObject):
8992
# This object exists because wrap_bio() doesn't
@@ -106,10 +109,15 @@ def wrap_socket(
106109
server_hostname: str | None = None,
107110
session: ssl.SSLSession | None = None,
108111
) -> ssl.SSLSocket:
109-
# Use a context manager here because the
110-
# inner SSLContext holds on to our state
111-
# but also does the actual handshake.
112-
with _configure_context(self._ctx):
112+
113+
# We need to lock around the .__enter__()
114+
# but we don't need to lock within the
115+
# context manager, so we need to expand the
116+
# syntactic sugar of the `with` statement.
117+
with contextlib.ExitStack() as stack:
118+
with self._ctx_lock:
119+
stack.enter_context(_configure_context(self._ctx))
120+
113121
ssl_sock = self._ctx.wrap_socket(
114122
sock,
115123
server_side=server_side,

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ resolvelib==1.2.0
1515
setuptools==70.3.0
1616
tomli==2.2.1
1717
tomli-w==1.2.0
18-
truststore==0.10.3
18+
truststore==0.10.4
1919
dependency-groups==1.3.1

0 commit comments

Comments
 (0)