Skip to content

hmac: improve bytes handling #9046

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

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdlib/hmac.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from _typeshed import ReadableBuffer
from _typeshed import ReadableBuffer, _BufferWithLen
from collections.abc import Callable
from types import ModuleType
from typing import Any, AnyStr, overload
Expand All @@ -18,9 +18,9 @@ if sys.version_info >= (3, 8):
# In reality digestmod has a default value, but the function always throws an error
# if the argument is not given, so we pretend it is a required argument.
@overload
def new(key: bytes, msg: ReadableBuffer | None, digestmod: _DigestMod) -> HMAC: ...
def new(key: bytes | bytearray, msg: ReadableBuffer | None, digestmod: _DigestMod) -> HMAC: ...
@overload
def new(key: bytes, *, digestmod: _DigestMod) -> HMAC: ...
def new(key: bytes | bytearray, *, digestmod: _DigestMod) -> HMAC: ...

else:
def new(key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod | None = ...) -> HMAC: ...
Expand All @@ -30,7 +30,7 @@ class HMAC:
block_size: int
@property
def name(self) -> str: ...
def __init__(self, key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod = ...) -> None: ...
def __init__(self, key: bytes | bytearray, msg: ReadableBuffer | None = ..., digestmod: _DigestMod = ...) -> None: ...
def update(self, msg: ReadableBuffer) -> None: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
Expand All @@ -40,4 +40,4 @@ class HMAC:
def compare_digest(__a: ReadableBuffer, __b: ReadableBuffer) -> bool: ...
@overload
def compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ...
def digest(key: bytes, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ...
def digest(key: _BufferWithLen, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ...