[issue12059] hashlib does not handle missing hash functions correctly

2011-05-14 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
assignee:  -> gregory.p.smith
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12059] hashlib does not handle missing hash functions correctly

2011-05-14 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 572fbd9ca28f by Gregory P. Smith in branch '2.7':
Fixes Issue #12059: Properly handle missing hash functions even when
http://hg.python.org/cpython/rev/572fbd9ca28f

New changeset ad9249f35914 by Gregory P. Smith in branch '3.2':
Fixes Issue #12059: Properly handle missing hash functions even when
http://hg.python.org/cpython/rev/ad9249f35914

New changeset 29fd46b0 by Gregory P. Smith in branch 'default':
Fixes Issue #12059: Properly handle missing hash functions even when
http://hg.python.org/cpython/rev/29fd46b0

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12059] hashlib does not handle missing hash functions correctly

2011-05-12 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +gregory.p.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12059] hashlib does not handle missing hash functions correctly

2011-05-11 Thread Ian Wienand

New submission from Ian Wienand :

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

---
$ python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
... raise ValueError
... 
>>> import _hashlib
>>> _hashlib.openssl_sha224 = foo
>>> import hashlib
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/hashlib.py", line 136, in 
md5 = __get_builtin_constructor('md5')
  File "/usr/lib/python2.6/hashlib.py", line 63, in __get_builtin_constructor
import _md5
ImportError: No module named _md5
>>> 
---

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

--
files: hashlib.py.diff
keywords: patch
messages: 135794
nosy: Ian.Wienand
priority: normal
severity: normal
status: open
title: hashlib does not handle missing hash functions correctly
type: behavior
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file21971/hashlib.py.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com