Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Feature or enhancement
This is a follow-up to#134696. Afterc6e63d9, it's now possible to use the following forms:
hashlib.new(name, data)hashlib.new(name, data=...)hashlib.new(name, string=...)
and, taking MD5 as an example,hashlib.md5(data),hashlib.md5(data=...) andhashlib.md5(string=...).
In thedocs we only expose the following signatures:
hashlib.new(name, [data, ]*, usedforsecurity=True)hashlib.md5([data, ]*, usedforsecurity=True)So, it would make sense to remove support forstring=.... Ideally, I want to make it positional-only, but I don't think it's worth the shot and it's too much for a breaking change.
Note that we could also deprecatedata itself because originally,PEP-247 andPEP-452 were usingstring and notdata, but this is probably confusing as the PEP says:
Although the parameter is called ‘string’, hashing objects operate on 8-bit data only. Both ‘key’ and ‘string’ must be a bytes-like object (bytes, bytearray…).
I assume that the docs decided to use 'data' to remove this ambiguity as 'data' is more common for bytes-like objects.
cc@gpshead