forked from python/typeshed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the ReadableBuffer type in more places
This is a follow-up on python#4232. memoryview, hashlib, and hmac are updated to use ReadableBuffer type instead of their own home-spun unions of bytes, bytearray and whatever else each use case used. mmap is being handled in python#4244, and I'll leave BinaryIO for another day (or possibly another person) because it's going to require some messy code duplication because the relevant methods are defined in IO[AnyStr]. There's one corner case I'm not quite sure how best to handle: the documentation for hmac.digest claim that the parmaeters have the same meanings as in hmac.new, but in CPython the latter has an explicit check that `key` is bytes or bytearray while the former works with a memory-view. For now I've matched the documentation. Also, the documentation for HMAC.update says that `msg` can be any type supported by hashlib from Python 3.4; but I can't see anything in the Python 2.7 implementation that would prevent it also taking bytes-like objects, so I've not tried to treat Python 2 any different to Python 3.
- Loading branch information
Showing
4 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters