diff -ur a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py --- a/Lib/test/test_bytes.py 2016-12-09 19:05:07.000000000 -0500 +++ b/Lib/test/test_bytes.py 2016-12-09 19:05:51.000000000 -0500 @@ -293,6 +293,7 @@ b = bytearray([0x1a, 0x2b, 0x30]) self.assertEqual(self.type2test.fromhex('1a2B30'), b) self.assertEqual(self.type2test.fromhex(' 1A 2B 30 '), b) + self.assertEqual(self.type2test.fromhex(' 1A\n2B\t30\v'), b) self.assertEqual(self.type2test.fromhex('0000'), b'\0\0') self.assertRaises(TypeError, self.type2test.fromhex, b'1B') self.assertRaises(ValueError, self.type2test.fromhex, 'a') diff -ur a/Objects/bytesobject.c b/Objects/bytesobject.c --- a/Objects/bytesobject.c 2016-12-09 19:01:49.000000000 -0500 +++ b/Objects/bytesobject.c 2016-12-09 19:02:39.000000000 -0500 @@ -2379,10 +2379,10 @@ end = str + hexlen; while (str < end) { /* skip over spaces in the input */ - if (*str == ' ') { + if (Py_ISSPACE(*str)) { do { str++; - } while (*str == ' '); + } while (Py_ISSPACE(*str)); if (str >= end) break; }