This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: allow hashlib `update' to accept str
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, gregory.p.smith, ksqsf, pitrou, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-08-17 10:59 by ksqsf, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg300406 - (view) Author: ksqsf (ksqsf) Date: 2017-08-17 10:59
It'll be nice if `update' can accept str directly, rather than str.encode first.

One of the most common use cases is "m.update(s.encode())", so it shouldn't make a big difference to just use "m.update(s)"; after all, users who want to specify encoding explicitly can still do so.
msg300409 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2017-08-17 12:24
This will never happen as this is precisely the kind of confusion Python 3 was designed to avoid.
msg300411 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-17 12:32
Explicit is better than implicit.

It is easy to add ".encode()" in the user code if it needs this.  Adding this feature has non-zero (and actually not a small) cost. Since update() is not just a method, but a part of a protocol, you need to update all implementations. On other hand, raising an error on string argument can help to catch an error if a string unexpectedly occurred instead of a bytes object.
msg300459 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-08-17 21:56
Yes, what Antoine and Serhiy said.
History
Date User Action Args
2022-04-11 14:58:50adminsetgithub: 75408
2017-08-17 21:56:57christian.heimessetmessages: + msg300459
2017-08-17 12:32:08serhiy.storchakasetnosy: + gregory.p.smith, serhiy.storchaka, christian.heimes

messages: + msg300411
versions: + Python 3.7, - Python 3.6
2017-08-17 12:24:43pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg300409

resolution: rejected
stage: resolved
2017-08-17 10:59:35ksqsfcreate