[New-bugs-announce] [issue4771] Bad examples in hashlib documentation

David M. Beazley report at bugs.python.org
Mon Dec 29 20:54:13 CET 2008

New submission from David M. Beazley <beazley at users.sourceforge.net>:

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

>>> hashlib.sha224(b"Nobody inspects the spammish 

and this one

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

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

>>> h.hexdigest()

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 <report at bugs.python.org>

More information about the New-bugs-announce mailing list