diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index c2fc13e8db3d5d..d3331bbb932da8 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -460,10 +460,10 @@ def test_fromhex(self): self.assertRaises(ValueError, self.type2test.fromhex, '12 \x00 34') # For odd number of character(s) - for value in ("a", "a ", " a"," a ", "aaa", "aaa ", " aaa", " aaa ", " aa a "): + for value in ("a", "a ", " a"," a ", "aaa", "aaa ", " aaa", " aaa "): with self.assertRaises(ValueError) as cm: self.type2test.fromhex(value) - self.assertIn("fromhex() arg must be of even length", str(cm.exception)) + self.assertIn("fromhex() arg must contain an even number of hexadecimal digits", str(cm.exception)) for data, pos in ( # invalid first hexadecimal character diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 4f8a48c20c1f7a..b59c414c7cbf81 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2562,7 +2562,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray) error: if (invalid_char == -1) { PyErr_SetString(PyExc_ValueError, - "fromhex() arg must be of even length"); + "fromhex() arg must contain an even number of hexadecimal digits"); } else { PyErr_Format(PyExc_ValueError, "non-hexadecimal number found in "