[New-bugs-announce] [issue6281] Bug in hashlib

Daniel Eloff report at bugs.python.org
Sun Jun 14 00:45:31 CEST 2009


New submission from Daniel Eloff <dan.eloff at gmail.com>:

The try statement at the end of hashlib.py is some of the worst python
code I've had the mispleasure of reading for a long time.

Secondly, it seems flawed in function as well as form.
__get_builtin_constructor can throw an ImportError, which seems
erroneously caught in the except (why on earth does the except span more
than the "import _hashlib"? That's bad style for precisely this reason.)
This will cause an error in the import of hashlib when there are
possibly many working hash functions already imported. Changing the:

try:
    exec funcName + ' = __get_builtin_constructor(funcName)'
except ValueError:
    pass

to catch ImportError as well solves the problem for me.

----------
messages: 89338
nosy: Eloff
severity: normal
status: open
title: Bug in hashlib
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6281>
_______________________________________


More information about the New-bugs-announce mailing list