-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
smtplib: Improve bytes handling #9094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import sys | ||
from _typeshed import Self | ||
from _typeshed import ReadableBuffer, Self, _BufferWithLen | ||
from collections.abc import Sequence | ||
from email.message import Message as _Message | ||
from re import Pattern | ||
|
@@ -9,6 +9,8 @@ from types import TracebackType | |
from typing import Any, Protocol, overload | ||
from typing_extensions import TypeAlias | ||
|
||
from _socket import _Address as _SourceAddress | ||
|
||
__all__ = [ | ||
"SMTPException", | ||
"SMTPServerDisconnected", | ||
|
@@ -28,8 +30,6 @@ __all__ = [ | |
|
||
_Reply: TypeAlias = tuple[int, bytes] | ||
_SendErrs: TypeAlias = dict[str, _Reply] | ||
# Should match source_address for socket.create_connection | ||
_SourceAddress: TypeAlias = tuple[bytearray | bytes | str, int] | ||
|
||
SMTP_PORT: int | ||
SMTP_SSL_PORT: int | ||
|
@@ -102,7 +102,7 @@ class SMTP: | |
) -> None: ... | ||
def set_debuglevel(self, debuglevel: int) -> None: ... | ||
def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ... | ||
def send(self, s: bytes | str) -> None: ... | ||
def send(self, s: ReadableBuffer | str) -> None: ... | ||
def putcmd(self, cmd: str, args: str = ...) -> None: ... | ||
def getreply(self) -> _Reply: ... | ||
def docmd(self, cmd: str, args: str = ...) -> _Reply: ... | ||
|
@@ -114,7 +114,7 @@ class SMTP: | |
def noop(self) -> _Reply: ... | ||
def mail(self, sender: str, options: Sequence[str] = ...) -> _Reply: ... | ||
def rcpt(self, recip: str, options: Sequence[str] = ...) -> _Reply: ... | ||
def data(self, msg: bytes | str) -> _Reply: ... | ||
def data(self, msg: ReadableBuffer | str) -> _Reply: ... | ||
def verify(self, address: str) -> _Reply: ... | ||
vrfy = verify | ||
def expn(self, address: str) -> _Reply: ... | ||
|
@@ -125,16 +125,16 @@ class SMTP: | |
@overload | ||
def auth_cram_md5(self, challenge: None = ...) -> None: ... | ||
@overload | ||
def auth_cram_md5(self, challenge: bytes) -> str: ... | ||
def auth_plain(self, challenge: bytes | None = ...) -> str: ... | ||
def auth_login(self, challenge: bytes | None = ...) -> str: ... | ||
def auth_cram_md5(self, challenge: ReadableBuffer) -> str: ... | ||
def auth_plain(self, challenge: ReadableBuffer | None = ...) -> str: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The next one doesn't really use it either, I figured I should be consistent with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that makes sense, I figured as much! |
||
def auth_login(self, challenge: ReadableBuffer | None = ...) -> str: ... | ||
def login(self, user: str, password: str, *, initial_response_ok: bool = ...) -> _Reply: ... | ||
def starttls(self, keyfile: str | None = ..., certfile: str | None = ..., context: SSLContext | None = ...) -> _Reply: ... | ||
def sendmail( | ||
self, | ||
from_addr: str, | ||
to_addrs: str | Sequence[str], | ||
msg: bytes | str, | ||
msg: _BufferWithLen | str, | ||
mail_options: Sequence[str] = ..., | ||
rcpt_options: Sequence[str] = ..., | ||
) -> _SendErrs: ... | ||
|
Uh oh!
There was an error while loading. Please reload this page.