From fea57ad0957a6c4a36bc3d39d96d6e4c9a9ab45f Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 21 Feb 2023 18:24:34 +0000 Subject: [PATCH] `hmac.HMAC`: `digestmod` defaults to `None` on py37 (#9790) --- stdlib/hmac.pyi | 8 +++++++- tests/stubtest_allowlists/py37.txt | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/stdlib/hmac.pyi b/stdlib/hmac.pyi index b9a867f7b..ee8af1b48 100644 --- a/stdlib/hmac.pyi +++ b/stdlib/hmac.pyi @@ -30,7 +30,13 @@ class HMAC: block_size: int @property def name(self) -> str: ... - def __init__(self, key: bytes | bytearray, msg: ReadableBuffer | None = None, digestmod: _DigestMod = "") -> None: ... + if sys.version_info >= (3, 8): + def __init__(self, key: bytes | bytearray, msg: ReadableBuffer | None = None, digestmod: _DigestMod = "") -> None: ... + else: + def __init__( + self, key: bytes | bytearray, msg: ReadableBuffer | None = None, digestmod: _DigestMod | None = None + ) -> None: ... + def update(self, msg: ReadableBuffer) -> None: ... def digest(self) -> bytes: ... def hexdigest(self) -> str: ... diff --git a/tests/stubtest_allowlists/py37.txt b/tests/stubtest_allowlists/py37.txt index 3c9a5357e..f83cd84b6 100644 --- a/tests/stubtest_allowlists/py37.txt +++ b/tests/stubtest_allowlists/py37.txt @@ -32,7 +32,6 @@ dummy_threading.Condition.release dummy_threading.Event.isSet dummy_threading.local.__new__ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve -hmac.HMAC.__init__ inspect.Signature.from_builtin # Removed in 3.11, can add if someone needs this inspect.Signature.from_function # Removed in 3.11, can add if someone needs this ipaddress._BaseNetwork.__init__