mirror of
https://github.com/python/cpython.git
synced 2025-10-21 06:02:21 +00:00
gh-127740: For odd-length input to bytes.fromhex(...) change the error message to ValueError: fromhex() arg must be of even length (#127756)
This commit is contained in:
parent
12b4f1a5a1
commit
db9bea0386
3 changed files with 23 additions and 4 deletions
|
@ -459,6 +459,12 @@ class BaseBytesTest:
|
|||
self.assertRaises(ValueError, self.type2test.fromhex, '\x00')
|
||||
self.assertRaises(ValueError, self.type2test.fromhex, '12 \x00 34')
|
||||
|
||||
# For odd number of character(s)
|
||||
for value in ("a", "aaa", "deadbee"):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
self.type2test.fromhex(value)
|
||||
self.assertIn("fromhex() arg must contain an even number of hexadecimal digits", str(cm.exception))
|
||||
|
||||
for data, pos in (
|
||||
# invalid first hexadecimal character
|
||||
('12 x4 56', 3),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue