Skip to content

Raise TypeError in pure Python hmac.digest for non-bytes keys #155426

Description

@picnixz

Bug report

Bug description:

hmac.digest() reaches key.ljust() with a key type its own class rejects by name, so hmac.digest(memoryview(key), msg, "md5") raises AttributeError instead of TypeError as hmac.HMAC does. I'm aligning the exceptions here but I may consider accepting other types later.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions