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.

Author Lennart Grahl
Recipients Lennart Grahl, docs@python
Date 2016-05-25.15:55:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464191758.68.0.963867406137.issue27124@psf.upfronthosting.co.za>
In-reply-to
Content
When using binascii.a2b_hex (or binascii.unhexlify) and the argument is invalid, the doc states that it should raise a TypeError for invalid arguments (e.g. passing an odd-length string).

However, it does raise binascii.Error instead of TypeError:

try:
    binascii.a2b_hex('a')
except Exception as exc:
    print(type(exc))

What surprised me even more was that it raises ValueError (although binascii.Error inherits ValueError) in case a unicode string has been passed as an argument:

try:
    binascii.a2b_hex('ä')
except binascii.Error:
    print('binascii.Error')
except ValueError:
    print('ValueError')
History
Date User Action Args
2016-05-25 15:55:58Lennart Grahlsetrecipients: + Lennart Grahl, docs@python
2016-05-25 15:55:58Lennart Grahlsetmessageid: <1464191758.68.0.963867406137.issue27124@psf.upfronthosting.co.za>
2016-05-25 15:55:58Lennart Grahllinkissue27124 messages
2016-05-25 15:55:58Lennart Grahlcreate