Lennart Grahl added the comment:
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')
----------
title: binascii.a2b_hex raises binascii.Error, not TypeError ->
binascii.a2b_hex raises binascii.Error and ValueError, not TypeError
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27124>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com