Issue 12059: hashlib does not handle missing hash functions correctly (original) (raw)

If one of the hash functions isn't defined in _hashlib, the code suggests it should just be skipped

=== # this one has no builtin implementation, don't define it pass

This doesn't happen however; due to ImportError not being caught the module decides the whole _hashlib module isn't available and tries to fall back to the older individual libraries. You then get thrown an unrelated error about _md5 being unavailable

You can easily replicate this


I think the solution is to catch the ImportError in __get_builtin_constructor and, if caught, consider the hash function unsupported