diff -r 1f466354a85b Lib/sre_compile.py --- a/Lib/sre_compile.py Mon Oct 21 09:08:39 2013 +0200 +++ b/Lib/sre_compile.py Mon Oct 21 14:18:57 2013 +0300 @@ -339,7 +339,7 @@ else: code = 'I' # Convert block indices to byte array of 256 bytes - mapping = array.array('b', mapping).tobytes() + mapping = array.array('B', mapping).tobytes() # Convert byte array to word array mapping = array.array(code, mapping) assert mapping.itemsize == _sre.CODESIZE diff -r 1f466354a85b Lib/test/test_re.py --- a/Lib/test/test_re.py Mon Oct 21 09:08:39 2013 +0200 +++ b/Lib/test/test_re.py Mon Oct 21 14:18:57 2013 +0300 @@ -482,6 +482,9 @@ "\u2222").group(1), "\u2222") self.assertEqual(re.match("([\u2222\u2223])", "\u2222", re.UNICODE).group(1), "\u2222") + r = '[%s]' % ''.join(map(chr, range(256, 2**16, 255))) + self.assertEqual(re.match(r, + "\uff01", re.UNICODE).group(), "\uff01") def test_big_codesize(self): # Issue #1160 diff -r 1f466354a85b Modules/_sre.c --- a/Modules/_sre.c Mon Oct 21 09:08:39 2013 +0200 +++ b/Modules/_sre.c Mon Oct 21 14:18:57 2013 +0300 @@ -457,7 +457,7 @@ /* !(c & ~N) == (c < N+1) for any unsigned c, this avoids * warnings when c's type supports only numbers < N+1 */ if (!(ch & ~65535)) - block = ((char*)set)[ch >> 8]; + block = ((unsigned char*)set)[ch >> 8]; else block = -1; set += 64;