Skip to content

Commit c50a708

Browse files
authored
Update poplib and smtplib for py312 (#10685)
1 parent 53144ca commit c50a708

File tree

8 files changed

+52
-27
lines changed

8 files changed

+52
-27
lines changed

stdlib/poplib.pyi

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import socket
22
import ssl
3+
import sys
34
from builtins import list as _list # conflicts with a method named "list"
45
from re import Pattern
56
from typing import Any, BinaryIO, NoReturn, overload
@@ -51,14 +52,20 @@ class POP3:
5152
def stls(self, context: ssl.SSLContext | None = None) -> bytes: ...
5253

5354
class POP3_SSL(POP3):
54-
def __init__(
55-
self,
56-
host: str,
57-
port: int = 995,
58-
keyfile: str | None = None,
59-
certfile: str | None = None,
60-
timeout: float = ...,
61-
context: ssl.SSLContext | None = None,
62-
) -> None: ...
63-
# "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored
64-
def stls(self, context: Any = None, keyfile: Any = None, certfile: Any = None) -> NoReturn: ...
55+
if sys.version_info >= (3, 12):
56+
def __init__(
57+
self, host: str, port: int = 995, *, timeout: float = ..., context: ssl.SSLContext | None = None
58+
) -> None: ...
59+
def stls(self, context: Any = None) -> NoReturn: ...
60+
else:
61+
def __init__(
62+
self,
63+
host: str,
64+
port: int = 995,
65+
keyfile: str | None = None,
66+
certfile: str | None = None,
67+
timeout: float = ...,
68+
context: ssl.SSLContext | None = None,
69+
) -> None: ...
70+
# "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored
71+
def stls(self, context: Any = None, keyfile: Any = None, certfile: Any = None) -> NoReturn: ...

stdlib/smtplib.pyi

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ class SMTP:
128128
def auth_plain(self, challenge: ReadableBuffer | None = None) -> str: ...
129129
def auth_login(self, challenge: ReadableBuffer | None = None) -> str: ...
130130
def login(self, user: str, password: str, *, initial_response_ok: bool = True) -> _Reply: ...
131-
def starttls(self, keyfile: str | None = None, certfile: str | None = None, context: SSLContext | None = None) -> _Reply: ...
131+
if sys.version_info >= (3, 12):
132+
def starttls(self, *, context: SSLContext | None = None) -> _Reply: ...
133+
else:
134+
def starttls(
135+
self, keyfile: str | None = None, certfile: str | None = None, context: SSLContext | None = None
136+
) -> _Reply: ...
137+
132138
def sendmail(
133139
self,
134140
from_addr: str,
@@ -152,17 +158,29 @@ class SMTP_SSL(SMTP):
152158
keyfile: str | None
153159
certfile: str | None
154160
context: SSLContext
155-
def __init__(
156-
self,
157-
host: str = "",
158-
port: int = 0,
159-
local_hostname: str | None = None,
160-
keyfile: str | None = None,
161-
certfile: str | None = None,
162-
timeout: float = ...,
163-
source_address: _SourceAddress | None = None,
164-
context: SSLContext | None = None,
165-
) -> None: ...
161+
if sys.version_info >= (3, 12):
162+
def __init__(
163+
self,
164+
host: str = "",
165+
port: int = 0,
166+
local_hostname: str | None = None,
167+
*,
168+
timeout: float = ...,
169+
source_address: _SourceAddress | None = None,
170+
context: SSLContext | None = None,
171+
) -> None: ...
172+
else:
173+
def __init__(
174+
self,
175+
host: str = "",
176+
port: int = 0,
177+
local_hostname: str | None = None,
178+
keyfile: str | None = None,
179+
certfile: str | None = None,
180+
timeout: float = ...,
181+
source_address: _SourceAddress | None = None,
182+
context: SSLContext | None = None,
183+
) -> None: ...
166184

167185
LMTP_PORT: int
168186

tests/stubtest_allowlists/py310.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ json.encoder.i
119119
lib2to3.pgen2.grammar.line
120120
lib2to3.pgen2.grammar.name
121121
lib2to3.pgen2.grammar.op
122+
poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
122123
pydoc.Helper.symbol # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
123124
pydoc.Helper.symbols_ # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
124125
pydoc.Helper.topic # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522

tests/stubtest_allowlists/py311.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
6969
http.HTTPMethod.description # mutable instance attribute at runtime but we pretend it's a property
7070
inspect._ParameterKind.description # Still exists, but stubtest can't see it
7171
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
72+
poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
7273
types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392
7374
types.GenericAlias.__getattr__
7475
types.GenericAlias.__mro_entries__

tests/stubtest_allowlists/py312.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ enum.EnumType.__call__
66
enum.property.member
77
http.client.HTTPConnection.get_proxy_response_headers
88
imaplib.IMAP4_SSL.__init__
9-
poplib.POP3_SSL.__init__
10-
smtplib.SMTP.starttls
11-
smtplib.SMTP_SSL.__init__
129
urllib.request.AbstractHTTPHandler.__init__
1310
urllib.request.HTTPSHandler.__init__
1411

tests/stubtest_allowlists/py38.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ json.encoder.i
115115
lib2to3.pgen2.grammar.line
116116
lib2to3.pgen2.grammar.name
117117
lib2to3.pgen2.grammar.op
118+
poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
118119
pydoc.Helper.symbol # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
119120
pydoc.Helper.symbols_ # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
120121
pydoc.Helper.topic # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522

tests/stubtest_allowlists/py39.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ json.encoder.i
9595
lib2to3.pgen2.grammar.line
9696
lib2to3.pgen2.grammar.name
9797
lib2to3.pgen2.grammar.op
98+
poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
9899
pydoc.Helper.symbol # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
99100
pydoc.Helper.symbols_ # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
100101
pydoc.Helper.topic # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522

tests/stubtest_allowlists/py3_common.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ multiprocessing.synchronize.SemLock.release
108108
numbers.Number.__hash__ # typeshed marks this as abstract but code just sets this as None
109109
optparse.Values.__getattr__ # Some attributes are set in __init__ using setattr
110110
pickle.Pickler.reducer_override # implemented in C pickler
111-
poplib.POP3_SSL.stls # bad declaration of inherited function. See poplib.pyi
112111
pyexpat.expat_CAPI
113112
select.poll # Depends on configuration
114113
selectors.DevpollSelector # Depends on configuration

0 commit comments

Comments
 (0)