ValueError when calling inspect.signature on hashlib.md5

34 Views Asked by At

I am encountering an exception when attempting to retrieve the signature of the hashlib.md5 function:

inspect.signature(hashlib.md5)

ValueError: 'usedforsecurity=?' is not a valid parameter name

on Python 3.10.8. What could be the reason and how can I avoid this?

1

There are 1 best solutions below

4
mcsoini On

This could be traced back to the installation of the conda gcc package. The underlying reason remains unknown. Full reproducible example:

# 1. set up new environment
conda create -n pythontest python==3.10
conda activate pythontest

# 2. test python command in fresh environment
python -c "import hashlib, inspect; print(inspect.signature(hashlib.md5))"

# output as expected: (string=b'', *, usedforsecurity=True)

# 3. install gcc
conda install -c conda-forge gcc=12.1.0

# 4. rerun python command
python -c "import hashlib, inspect; print(inspect.signature(hashlib.md5))"

# ValueError: 'usedforsecurity=?' is not a valid parameter name

In my particular case, gcc was installed due to this answer solving the common 'GLIBCXX_3.4.30' not found error.

I am now avoiding installing gcc by using this alternative approach.