[Python-Dev] hashlib bug when built on OS X 10.6 for 10.5 (original) (raw)

Arnaud Bergeron abergeron at gmail.com
Wed Oct 6 22:26:57 CEST 2010


If you build python (at least 2.6.5, but probably other versions as well) in a universal setup using the following command (or similar) while the machine currently has 10.6 installed:

./configure --with-universal-archs=<doesn't matter> --enable-universalsdk=/Developer/SDKs/MacOSX10.5.sdk/

then the hashlib module will be unimportable with the following error:

ImportError: No module named _md5

This is because the openssl detection code in setup.py picks up the system libssl (in /) which is 0.9.8 and selects not to build the additional _sha256, and _sh512 modules. Then, when the builds proceeds the SDK libssl is used (in /Developer/SDKs/MacOSX10.5.sdk/) which is version 0.9.7 and the openssl_sha256 and openssl_sha512 raise ValueError in the _hashlib that is built.

Then the fancy code in hashlib.py detects the ValueError, tries to import _sha256 and gets an ImportError which is caught by the code set to catch an ImportError of _hashlib and this codes tries to import _md5 which also fails and gives the error above.

In summary, the code in setup.py finds the wrong library and this creates a situation with which hashlib.py is not ready to handle.

If the analysis is not clear on certain points, feel free to ask questions.

Arnaud



More information about the Python-Dev mailing list