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: Docs discourage use of binascii.unhexlify etc.
Type: Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Devin Jeanpierre, docs@python, r.david.murray
Priority: normal Keywords:

Created on 2015-05-07 22:10 by Devin Jeanpierre, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg242737 - (view) Author: Devin Jeanpierre (Devin Jeanpierre) * Date: 2015-05-07 22:10
Maybe the functions should be split up into those you shouldn't need to call directly, and those you should? I find it unlikely that you're supposed to use codecs.encode(..., 'hex') and codecs.decode(..., 'hex') instead of binascii (the only other thing, AFAIK, that works in both 2 and 3).

Relevant quote starts with: "Normally, you will not use these functions directly"

https://docs.python.org/2/library/binascii
https://docs.python.org/3/library/binascii
msg242738 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-07 22:51
No, actually, using codecs would be the most straightforward way to achieve portability.  The usual way to get hex in python2 was encode('hex'), which uses the codec.  But if you want to use hexlify instead, I don't see any reason not to.  There's no reason to change the binascii module description, though, since it is talking about normal code, not 2/3 shared source code (where you do sometimes have to jump through somewhat awkward hoops).

(The One Obvious Way starting with 3.5 will be b'abcde'.hex(), but of course that isn't python2 compatible.)
History
Date User Action Args
2022-04-11 14:58:16adminsetgithub: 68332
2015-05-07 22:51:21r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg242738

resolution: not a bug
stage: resolved
2015-05-07 22:10:35Devin Jeanpierrecreate