[issue4771] Bad examples in hashlib documentation

2008-12-29 Thread David M. Beazley

New submission from David M. Beazley :

The hashlib documentation has incorrect examples showing the use of the 
hexdigest() method:

>>> hashlib.sha224(b"Nobody inspects the spammish 
repetition").hexdigest()
b'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
>>>

and this one

>>> h = hashlib.new('ripemd160')
>>> h.update(b"Nobody inspects the spammish repetition")
>>> h.hexdigest()
b'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
>>>

However, the result of h.hexdigest() is of type 'str', not bytes. Actual 
output:

>>> h.hexdigest()
'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
>>> 

Sure would be nice if that string of hex digits was easy to decode back 
into a binary string.  

>>> import binascii
>>> b = binascii.a2b_hex(h.hexdigest())
>>>

Hmmm. So *SOME* of the functions in binascii do accept Unicode strings. 
See Issue 4470 :-).

--
assignee: georg.brandl
components: Documentation
messages: 78480
nosy: beazley, georg.brandl
severity: normal
status: open
title: Bad examples in hashlib documentation
type: behavior
versions: Python 3.0

___
Python tracker 

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



[issue4771] Bad examples in hashlib documentation

2008-12-29 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Shouldn't hash algorithms give bytes results anyway?

--
components: +Library (Lib) -Documentation
nosy: +benjamin.peterson
priority:  -> release blocker

___
Python tracker 

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



[issue4771] Bad examples in hashlib documentation

2008-12-29 Thread David M. Beazley

David M. Beazley  added the comment:

The digest() method of hashes does produce bytes (correct).   The 
hexdigest() method produces a string, but it is also shown as producing 
bytes in the examples.

___
Python tracker 

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



[issue4771] Bad examples in hashlib documentation

2008-12-29 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Fixed in r68027.

--
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