]> granicus.if.org Git - python/commitdiff
Issue #19327: Fixed the working of regular expressions with too big charset.
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 24 Oct 2013 19:02:42 +0000 (22:02 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 24 Oct 2013 19:02:42 +0000 (22:02 +0300)
Lib/sre_compile.py
Lib/test/test_re.py
Misc/NEWS

index 97c1663b0b96d8807f1afb67fc0c77ec6dee46b0..bd4070549a9db717c4d8b2d3474d3da25617fecb 100644 (file)
@@ -343,7 +343,7 @@ def _optimize_unicode(charset, fixup):
     else:
         code = 'I'
     # Convert block indices to byte array of 256 bytes
-    mapping = array.array('b', mapping).tostring()
+    mapping = array.array('B', mapping).tostring()
     # Convert byte array to word array
     mapping = array.array(code, mapping)
     assert mapping.itemsize == _sre.CODESIZE
index 8b277cfc02ec298f0abfa8a22479c7a7a1ab7ddf..d879bac5f6e5c1ed8452d7df211175e513ffe3f5 100644 (file)
@@ -427,6 +427,8 @@ class ReTests(unittest.TestCase):
                                   u"\u2222").group(1), u"\u2222")
         self.assertEqual(re.match(u"([\u2222\u2223])",
                                   u"\u2222", re.UNICODE).group(1), u"\u2222")
+        r = u'[%s]' % u''.join(map(unichr, range(256, 2**16, 255)))
+        self.assertEqual(re.match(r, u"\uff01", re.UNICODE).group(), u"\uff01")
 
     def test_big_codesize(self):
         # Issue #1160
index 4e8dab8fc21d11411f4b4c8bcff8bc4b42c29ecf..5dc28700425113eea4b4775a2eeab9794bd64d4d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #19327: Fixed the working of regular expressions with too big charset.
+
 - Issue #19350: Increasing the test coverage of macurl2path. Patch by Colin
   Williams.