Skip to content

Commit fd5c6d4

Browse files
authored
[ssl] Add missing default values (#14472)
* Move few functions to be able to use variables as default value * Unify deprecated messages
1 parent 7863f01 commit fd5c6d4

File tree

1 file changed

+42
-44
lines changed

1 file changed

+42
-44
lines changed

stdlib/ssl.pyi

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -93,46 +93,6 @@ if sys.version_info < (3, 12):
9393
suppress_ragged_eofs: bool = True,
9494
ciphers: str | None = None,
9595
) -> SSLSocket: ...
96-
97-
def create_default_context(
98-
purpose: Purpose = ...,
99-
*,
100-
cafile: StrOrBytesPath | None = None,
101-
capath: StrOrBytesPath | None = None,
102-
cadata: str | ReadableBuffer | None = None,
103-
) -> SSLContext: ...
104-
105-
if sys.version_info >= (3, 10):
106-
def _create_unverified_context(
107-
protocol: int | None = None,
108-
*,
109-
cert_reqs: int = ...,
110-
check_hostname: bool = False,
111-
purpose: Purpose = ...,
112-
certfile: StrOrBytesPath | None = None,
113-
keyfile: StrOrBytesPath | None = None,
114-
cafile: StrOrBytesPath | None = None,
115-
capath: StrOrBytesPath | None = None,
116-
cadata: str | ReadableBuffer | None = None,
117-
) -> SSLContext: ...
118-
119-
else:
120-
def _create_unverified_context(
121-
protocol: int = ...,
122-
*,
123-
cert_reqs: int = ...,
124-
check_hostname: bool = False,
125-
purpose: Purpose = ...,
126-
certfile: StrOrBytesPath | None = None,
127-
keyfile: StrOrBytesPath | None = None,
128-
cafile: StrOrBytesPath | None = None,
129-
capath: StrOrBytesPath | None = None,
130-
cadata: str | ReadableBuffer | None = None,
131-
) -> SSLContext: ...
132-
133-
_create_default_https_context: Callable[..., SSLContext]
134-
135-
if sys.version_info < (3, 12):
13696
@deprecated("Deprecated since Python 3.7. Removed in Python 3.12.")
13797
def match_hostname(cert: _PeerCertRetDictType, hostname: str) -> None: ...
13898

@@ -372,7 +332,7 @@ class SSLSocket(socket.socket):
372332
def get_channel_binding(self, cb_type: str = "tls-unique") -> bytes | None: ...
373333
def selected_alpn_protocol(self) -> str | None: ...
374334
if sys.version_info >= (3, 10):
375-
@deprecated("Deprecated in 3.10. Use ALPN instead.")
335+
@deprecated("Deprecated since Python 3.10. Use ALPN instead.")
376336
def selected_npn_protocol(self) -> str | None: ...
377337
else:
378338
def selected_npn_protocol(self) -> str | None: ...
@@ -426,7 +386,7 @@ class SSLContext(_SSLContext):
426386
else:
427387
def __new__(cls, protocol: int = ..., *args: Any, **kwargs: Any) -> Self: ...
428388

429-
def load_default_certs(self, purpose: Purpose = ...) -> None: ...
389+
def load_default_certs(self, purpose: Purpose = Purpose.SERVER_AUTH) -> None: ...
430390
def load_verify_locations(
431391
self,
432392
cafile: StrOrBytesPath | None = None,
@@ -444,7 +404,7 @@ class SSLContext(_SSLContext):
444404
def set_ciphers(self, cipherlist: str, /) -> None: ...
445405
def set_alpn_protocols(self, alpn_protocols: Iterable[str]) -> None: ...
446406
if sys.version_info >= (3, 10):
447-
@deprecated("Deprecated in 3.10. Use ALPN instead.")
407+
@deprecated("Deprecated since Python 3.10. Use ALPN instead.")
448408
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
449409
else:
450410
def set_npn_protocols(self, npn_protocols: Iterable[str]) -> None: ...
@@ -470,6 +430,44 @@ class SSLContext(_SSLContext):
470430
session: SSLSession | None = None,
471431
) -> SSLObject: ...
472432

433+
def create_default_context(
434+
purpose: Purpose = Purpose.SERVER_AUTH,
435+
*,
436+
cafile: StrOrBytesPath | None = None,
437+
capath: StrOrBytesPath | None = None,
438+
cadata: str | ReadableBuffer | None = None,
439+
) -> SSLContext: ...
440+
441+
if sys.version_info >= (3, 10):
442+
def _create_unverified_context(
443+
protocol: int | None = None,
444+
*,
445+
cert_reqs: int = ...,
446+
check_hostname: bool = False,
447+
purpose: Purpose = Purpose.SERVER_AUTH,
448+
certfile: StrOrBytesPath | None = None,
449+
keyfile: StrOrBytesPath | None = None,
450+
cafile: StrOrBytesPath | None = None,
451+
capath: StrOrBytesPath | None = None,
452+
cadata: str | ReadableBuffer | None = None,
453+
) -> SSLContext: ...
454+
455+
else:
456+
def _create_unverified_context(
457+
protocol: int = ...,
458+
*,
459+
cert_reqs: int = ...,
460+
check_hostname: bool = False,
461+
purpose: Purpose = Purpose.SERVER_AUTH,
462+
certfile: StrOrBytesPath | None = None,
463+
keyfile: StrOrBytesPath | None = None,
464+
cafile: StrOrBytesPath | None = None,
465+
capath: StrOrBytesPath | None = None,
466+
cadata: str | ReadableBuffer | None = None,
467+
) -> SSLContext: ...
468+
469+
_create_default_https_context = create_default_context
470+
473471
class SSLObject:
474472
context: SSLContext
475473
@property
@@ -490,7 +488,7 @@ class SSLObject:
490488
def getpeercert(self, binary_form: bool) -> _PeerCertRetType: ...
491489
def selected_alpn_protocol(self) -> str | None: ...
492490
if sys.version_info >= (3, 10):
493-
@deprecated("Deprecated in 3.10. Use ALPN instead.")
491+
@deprecated("Deprecated since Python 3.10. Use ALPN instead.")
494492
def selected_npn_protocol(self) -> str | None: ...
495493
else:
496494
def selected_npn_protocol(self) -> str | None: ...

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy