[New-bugs-announce] [issue40960] Fix the example in hashlib documentarion

Marcelo report at bugs.python.org
Fri Jun 12 07:36:43 EDT 2020


New submission from Marcelo <marcelogrsp at gmail.com>:

The documentation found in https://docs.python.org/2/library/hashlib.html

give us the following example:

```
More condensed:

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

Although, we get the error if not encode the string:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Unicode-objects must be encoded before hashing
```

So the example should be (string to bytes):
`hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()`

----------
assignee: docs at python
components: Documentation
messages: 371354
nosy: docs at python, marcelogrsp at gmail.com
priority: normal
severity: normal
status: open
title: Fix the example in hashlib documentarion
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40960>
_______________________________________


More information about the New-bugs-announce mailing list