Message266370
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') |
|
Date |
User |
Action |
Args |
2016-05-25 15:55:58 | Lennart Grahl | set | recipients:
+ Lennart Grahl, docs@python |
2016-05-25 15:55:58 | Lennart Grahl | set | messageid: <1464191758.68.0.963867406137.issue27124@psf.upfronthosting.co.za> |
2016-05-25 15:55:58 | Lennart Grahl | link | issue27124 messages |
2016-05-25 15:55:58 | Lennart Grahl | create | |
|