Skip to content

hashlib: fix arguments #3626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2020
Merged

hashlib: fix arguments #3626

merged 3 commits into from
Jan 22, 2020

Conversation

hauntsaninja
Copy link
Collaborator

  • fix argument names, so passing by keyword works
  • add default values to various args in scrypt, change types to Optional since default values are None

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! One suggestion.

def sha224(string: _DataType = ...) -> _Hash: ...
def sha256(string: _DataType = ...) -> _Hash: ...
def sha384(string: _DataType = ...) -> _Hash: ...
def sha512(string: _DataType = ...) -> _Hash: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this with Python 3.7.5:

>>> hashlib.md5(string="")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: openssl_md5() takes no keyword arguments

I suggest to mark them as positional-only arguments.

Copy link
Collaborator Author

@hauntsaninja hauntsaninja Jan 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it changed for py38:

>>> sys.version
'3.8.0 (default, Jan  3 2020, 22:27:51) \n[Clang 10.0.1 (clang-1001.0.46.4)]'
>>> hashlib.md5(string=b"")
<md5 HASH object @ 0x10f656b90>

I'll update the PR.

@srittau srittau merged commit e3dfaa6 into python:master Jan 22, 2020
@hauntsaninja hauntsaninja deleted the hashlib branch January 22, 2020 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants