Issue 33729: Hashlib/blake2* missing 'data' keyword argument (original) (raw)

Created on 2018-06-01 08:36 by Juuso Lehtivarjo, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 8346 merged serhiy.storchaka,2018-07-20 06:13
PR 8581 merged serhiy.storchaka,2018-07-31 06:57
PR 9657 merged serhiy.storchaka,2018-10-01 16:12
Messages (22)
msg318370 - (view) Author: Juuso Lehtivarjo (Juuso Lehtivarjo) Date: 2018-06-01 08:36
In python 3.6.5: hashlib blake2b/blake2s constructors do not recognize 'data' keyword. Try the following: from hashlib import blake2b print (blake2b(b"foobar").hexdigest()) # works print (blake2b(data=b"foobar").hexdigest()) # TypeError: 'data' is an invalid keyword argument for this function
msg321414 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-07-11 08:02
None of the hashlib functions are taking keyword arguments for data: >>> hashlib.sha256(data=b'foo') Traceback (most recent call last): File "", line 1, in TypeError: openssl_sha256() takes no keyword arguments >>> hashlib.blake2b(data=b'foo') Traceback (most recent call last): File "", line 1, in TypeError: 'data' is an invalid keyword argument for this function
msg321455 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-11 14:19
> None of the hashlib functions are taking keyword arguments for data: ... So it's just a documentation issue, no? https://docs.python.org/dev/library/hashlib.html#creating-hash-objects Juuso Lehtivarjo: do you want to write a pull request to fix the documentation?
msg321945 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-07-19 10:16
This was introduced as part of https://hg.python.org/cpython/rev/4969f6d343b1 . In addition to the signature there is also a line at https://docs.python.org/dev/library/hashlib.html#simple-hashing which could be removed > As a shortcut, you can pass the first chunk of data to update directly to the constructor as the first argument (or as data keyword argument) Thanks
msg321948 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-19 11:09
hashlib.blake2b() and some other constructors accept the first chunk of data as the "string" keyword argument. >>> hashlib.blake2b(string=b'') <_blake2.blake2b object at 0x7f2847a9c430> >>> hashlib.blake2s(string=b'') <_blake2.blake2s object at 0x7f28468f6290> >>> hashlib.sha3_224(string=b'') <_sha3.sha3_224 object at 0x7f28468f6608> >>> hashlib.sha3_256(string=b'') <_sha3.sha3_256 object at 0x7f28468f6290> >>> hashlib.sha3_384(string=b'') <_sha3.sha3_384 object at 0x7f28468f6608> >>> hashlib.sha3_512(string=b'') <_sha3.sha3_512 object at 0x7f28468f6290> >>> hashlib.shake_128(string=b'') <_sha3.shake_128 object at 0x7f28468f6608> >>> hashlib.shake_256(string=b'') <_sha3.shake_256 object at 0x7f28468f6290>
msg321949 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-07-19 11:20
Please treat the first argument as positional-only argument. I don't want to standardize on 'string'.
msg321955 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-19 12:05
I take this issue because there are many other issues with handling arguments in the hashlib module.
msg322732 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-31 06:50
New changeset f1d36d8efaecd5c84cb35e35119b283f37d83c40 by Serhiy Storchaka in branch 'master': bpo-33729: Fix issues with arguments parsing in hashlib. (GH-8346) https://github.com/python/cpython/commit/f1d36d8efaecd5c84cb35e35119b283f37d83c40
msg322738 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-31 07:22
New changeset 47957dab94a4efa2fee61c9a8193f78300950769 by Serhiy Storchaka in branch '3.7': [3.7] bpo-33729: Fix issues with arguments parsing in hashlib. (GH-8346) (GH-8581) https://github.com/python/cpython/commit/47957dab94a4efa2fee61c9a8193f78300950769
msg322740 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-07-31 07:26
Your PR changed way to many aspects of the code in one commit. I also don't like the fact, that you pushed such a big change without waiting for my feedback. For the past two weeks I have been travelling to conferences and had no time to review your PR. There was no need to rush it.
msg322741 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-07-31 07:28
The backport to 3.6 and 3.7 are breaking backwards compatibility and compatibility with PEP 247.
msg322744 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-31 08:06
Sorry. Do you prefer to revert the whole changes or just some parts?
msg322781 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-31 14:25
I have no opinion on the change in the master branch, but I agree with Christian that the 3.7 change should be reverted since it breaks the backward compatibility. Serhiy modified int() in Python 3.7 to convert its first parameter to positional only parameter. IMHO it's ok to do such change. Moreover, the change has been documented in What's New in Python 3.7: https://docs.python.org/dev/whatsnew/3.7.html#api-and-feature-removals If you decide to keep the change in the master branch, it should be documented in What's New in Python 3.8, no?
msg322798 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-31 16:22
In case of int() the name of it's first argument was documented, in both the module documentation, and in interactive help. But the documented name of the first blake2b() argument was "data", and it never worked. Since help() was not worked for blake2b, the user had weak chance to know that the actual name is "string". Thus there is much less chance of breaking the user code by making this parameter a positional-only than in case of int(). But I think Christian has other concerns.
msg327212 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-06 02:50
What's the status of this issue for 3.7 and for 3.6? Is everyone OK with what is currently in 3.7, i.e. no revert needed or has it already been reverted elsewhere? Also, there is the open PR for 3.6.
msg327256 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-10-06 17:52
Ned, I'm currently travelling until next weekend. The PR is rather large and I don't have any means or time to review it properly. Perhaps Gregory or Dmitry Chestnykh (original author of pyblake2) are able to assist.
msg327287 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-07 16:42
OK. This is now blocking the release of 3.7.1rc2 and 3.6.7rc2. See also Issue34922.
msg327303 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-07 19:08
The question remains if Christian's and Victor's concern with 3.7 compatibility have been satisfied by Serihy's response in . While there is plenty of time to resolve concerns about what was merged into master by PR 8346, we shouldn't release the PR 8581 changes in 3.7.1 if there are still valid compatibility concerns. Since PR 9657 for 3.6 hasn't been reviewed or merged, the only pressing issue for 3.6.7 is ensuring the segfault documented in Issue34922 is blocked, correct? And PR 8581 prevents the segfault for 3.7 so we would only need a similar fix for it if the PR were reverted, correct?
msg327304 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-07 19:37
I have reviewed PR 8346 yet one time. No documented working behavior was changed. Some documentation was updated to match the code, some code was updated to match the documentation, and other minor errors were fixed. I don't think this change breaks compatibility.
msg327305 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-07 19:40
Other variant of the crash in still is reproducible in 3.7.
msg327516 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-11 04:56
New changeset f543e18708efb04ed3a0b78c8dc31fbb1404ac7d by Serhiy Storchaka in branch '3.6': [3.6] bpo-33729: Fix issues with arguments parsing in hashlib. (GH-8346) (GH-8581) (GH-9657) https://github.com/python/cpython/commit/f543e18708efb04ed3a0b78c8dc31fbb1404ac7d
msg327675 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-13 21:58
Serhiy's fixes (thanks!) are now released in 3.7.0rc2 and 3.6.7rc2 so I'm removing the "release blocker" status. If there is nothing more to be done for this issue, can we close it?
History
Date User Action Args
2022-04-11 14:59:01 admin set github: 77910
2018-10-13 21:58:53 ned.deily set priority: release blocker -> messages: +
2018-10-11 04:56:11 serhiy.storchaka set messages: +
2018-10-07 19:40:47 serhiy.storchaka set messages: +
2018-10-07 19:37:01 serhiy.storchaka set messages: +
2018-10-07 19:08:07 ned.deily set messages: +
2018-10-07 16:42:16 ned.deily set priority: normal -> release blockermessages: +
2018-10-06 17:52:13 christian.heimes set nosy: + gregory.p.smithmessages: +
2018-10-06 02:50:55 ned.deily set nosy: + ned.deilymessages: +
2018-10-01 16:12:27 serhiy.storchaka set pull_requests: + <pull%5Frequest9049>
2018-09-03 15:21:59 serhiy.storchaka link issue34571 superseder
2018-07-31 16:22:18 serhiy.storchaka set messages: +
2018-07-31 14:25:07 vstinner set messages: +
2018-07-31 08:06:49 serhiy.storchaka set messages: +
2018-07-31 07:28:55 christian.heimes set messages: +
2018-07-31 07:26:48 christian.heimes set messages: +
2018-07-31 07:22:46 serhiy.storchaka set messages: +
2018-07-31 06:57:46 serhiy.storchaka set pull_requests: + <pull%5Frequest8090>
2018-07-31 06:50:19 serhiy.storchaka set messages: +
2018-07-20 06:13:54 serhiy.storchaka set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest7881>
2018-07-19 12:05:02 serhiy.storchaka set messages: +
2018-07-19 11:34:31 serhiy.storchaka set assignee: docs@python -> serhiy.storchaka
2018-07-19 11:20:56 christian.heimes set messages: +
2018-07-19 11:09:33 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2018-07-19 10:16:32 xtreak set nosy: + xtreakmessages: +
2018-07-11 14:19:01 vstinner set nosy: + docs@python, vstinnermessages: + assignee: docs@pythoncomponents: + Documentation
2018-07-11 08:02:42 christian.heimes set messages: + versions: + Python 3.7, Python 3.8
2018-07-11 07:54:46 serhiy.storchaka set type: crash -> behavior
2018-06-01 10:50:10 ned.deily set nosy: + christian.heimes
2018-06-01 08:36:11 Juuso Lehtivarjo create