Skip to content

Commit

Permalink
fix hashlib.blake2* signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
David Poirier authored and PCManticore committed Oct 15, 2018
1 parent cab26ec commit e930fb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions astroid/brain/brain_hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,19 @@ def digest_size(self):
["md5", "sha1", "sha224", "sha256", "sha384", "sha512"], signature
)
if PY36:
blake_signature = "value='', digest_size=None"
blake2b_signature = "data=b'', *, digest_size=64, key=b'', salt=b'', \
person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
node_depth=0, inner_size=0, last_node=False"
blake2s_signature = "data=b'', *, digest_size=32, key=b'', salt=b'', \
person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
node_depth=0, inner_size=0, last_node=False"
new_algorithms = dict.fromkeys(
["sha3_224", "sha3_256", "sha3_384", "sha3_512", "shake_128", "shake_256"],
signature,
)
algorithms_with_signature.update(new_algorithms)
algorithms_with_signature.update(
{"blake2b": blake_signature, "blake2s": blake_signature}
{"blake2b": blake2b_signature, "blake2s": blake2s_signature}
)
classes = "".join(
template
Expand Down
2 changes: 1 addition & 1 deletion astroid/tests/unittest_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_hashlib_py36(self):
self._assert_hashlib_class(class_obj)
for class_name in ["blake2b", "blake2s"]:
class_obj = hashlib_module[class_name]
self.assertEqual(len(class_obj["__init__"].args.args), 3)
self.assertEqual(len(class_obj["__init__"].args.args), 2)


class CollectionsDequeTests(unittest.TestCase):
Expand Down

0 comments on commit e930fb8

Please sign in to comment.