TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
See original GitHub issueEnvironment
- Operating system:
RedHat Linux inside an UBI8 Python 3.9 container image.
- Version of python you are running:
python --version
Python 3.9.6
- How did you install twine? Did you use your operating system’s package manager or pip or something else?
Using tox, as follows, running tox -e readme:
[testenv:readme]
description = Ensure README renders on PyPI
deps =
build
twine
commands =
{envpython} -m build
{envpython} -m twine check dist/*
- Version of twine you have installed (include complete output of):
twine --version
twine version 3.7.1 (importlib_metadata: 4.10.0, pkginfo: 1.8.2, requests:
2.27.1, requests-toolbelt: 0.9.1, tqdm: 4.62.3)
- Other: (maybe relevant)
My pyproject.toml looks like this:
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
The Issue
...
readme run-test: commands[6] | /builds/devsecops/git-malware-scanner/.tox/readme/bin/python -m twine check 'dist/*'
Traceback (most recent call last):
File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/__main__.py", line 53, in <module>
sys.exit(main())
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/__main__.py", line 28, in main
result = cli.dispatch(sys.argv[1:])
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/cli.py", line 71, in dispatch
return main(args.args)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/commands/check.py", line 191, in main
return check(parsed_args.dists, strict=parsed_args.strict)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/commands/check.py", line 135, in check
warnings, is_ok = _check_file(filename, render_warning_stream)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/commands/check.py", line 78, in _check_file
package = package_file.PackageFile.from_filename(filename, comment=None)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/package.py", line 128, in from_filename
return cls(filename, comment, meta, py_version, dtype)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/package.py", line 78, in __init__
hasher = HashManager(filename)
File "/builds/devsecops/git-malware-scanner/.tox/readme/lib/python3.9/site-packages/twine/package.py", line 261, in __init__
self._blake_hasher = hashlib.blake2b(digest_size=256 // 8)
TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
Checking dist/git_malware_scanner-1.0.0-py3-none-any.whl: ERROR: InvocationError for command /builds/devsecops/git-malware-scanner/.tox/readme/bin/python -m twine check 'dist/*' (exited with code 1)
I verified that:
- Python uses the
digest_sizekeyword argument (at least) since version 3.7 - The current and all older (tagged) versions of twine use blake2b(digest_size=…). It doesn’t seem to be an version issue.
Looking at the error message, it’s unclear to me why openssl_blake2b is mentioned (instead of just blake2b):
TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
Does this indicate that there is an incompatible library installed that takes precedence over the C-library that Python is meant to reference? Really just guessing. 🤔
Steps to Reproduce
- Pull and run the Docker image
registry.redhat.io/ubi8/python-39:latest - Prepare a
tox.iniwith the configuration shown above - Install
tox(pip install tox) and runtox
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
Issue 33729: Hashlib/blake2* missing 'data' keyword argument
None of the hashlib functions are taking keyword arguments for data: ... in <module> TypeError: 'data' is an invalid keyword argument for ...
Read more >Writing profile to disk fails because hashlib does not support ...
_x, usedforsecurity=False)).hexdigest() TypeError: openssl_md5() takes no keyword arguments.
Read more >15.1. hashlib — Secure hashes and message digests
This is a bytes object of size digest_size which may contain bytes in the whole range from 0 to 255. hash. hexdigest ()¶....
Read more >PyCryptodome Documentation - Read the Docs
Are RSASSA-PSS signatures compatible with Java or OpenSSL? ... Why does strxor raise TypeError: argument 2 must be bytes, not bytearray? 80.
Read more >TypeError: 'encoding' is an invalid keyword argument for this ...
My python program has trouble opening a text file. When I use the basic open file for read, I get an ascii error....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could we please reopen this issue. It seems that the problem is not in the twine but in our Python interpreter itself but it might be faster to discuss it here where we have all the details.
It seems to me that the problem is caused by using blake2b implementation from openssl. Python should prefer its own implementation of blake2b. The only possible reason I see for this situation is FIPS mode. Is there any chance that you have it enabled? Could you please try this:
RedHat has opened Bugzilla ticket #2041710 to track this case internally.