[Python-checkins] r59674 - in python/branches/release25-maint: Lib/sre_compile.py Lib/test/test_re.py Misc/NEWS
guido.van.rossum
python-checkins at python.org
Thu Jan 3 20:08:16 CET 2008
Author: guido.van.rossum
Date: Thu Jan 3 20:08:15 2008
New Revision: 59674
Modified:
python/branches/release25-maint/Lib/sre_compile.py
python/branches/release25-maint/Lib/test/test_re.py
python/branches/release25-maint/Misc/NEWS
Log:
Issue #1700, reported by Nguyen Quan Son, fix by Fredruk Lundh:
Regular Expression inline flags not handled correctly for some unicode
characters.
Modified: python/branches/release25-maint/Lib/sre_compile.py
==============================================================================
--- python/branches/release25-maint/Lib/sre_compile.py (original)
+++ python/branches/release25-maint/Lib/sre_compile.py Thu Jan 3 20:08:15 2008
@@ -525,7 +525,7 @@
indexgroup[i] = k
return _sre.compile(
- pattern, flags, code,
+ pattern, flags | p.pattern.flags, code,
p.pattern.groups-1,
groupindex, indexgroup
)
Modified: python/branches/release25-maint/Lib/test/test_re.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_re.py (original)
+++ python/branches/release25-maint/Lib/test/test_re.py Thu Jan 3 20:08:15 2008
@@ -637,6 +637,36 @@
self.assertEqual(re.compile("bla").match(a), None)
self.assertEqual(re.compile("").match(a).groups(), ())
+ def test_inline_flags(self):
+ # Bug #1700
+ upper_char = unichr(0x1ea0) # Latin Capital Letter A with Dot Bellow
+ lower_char = unichr(0x1ea1) # Latin Small Letter A with Dot Bellow
+
+ p = re.compile(upper_char, re.I | re.U)
+ q = p.match(lower_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile(lower_char, re.I | re.U)
+ q = p.match(upper_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?i)' + upper_char, re.U)
+ q = p.match(lower_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?i)' + lower_char, re.U)
+ q = p.match(upper_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?iu)' + upper_char)
+ q = p.match(lower_char)
+ self.assertNotEqual(q, None)
+
+ p = re.compile('(?iu)' + lower_char)
+ q = p.match(upper_char)
+ self.assertNotEqual(q, None)
+
+
def run_re_tests():
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose:
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Thu Jan 3 20:08:15 2008
@@ -53,6 +53,9 @@
Library
-------
+- Issue #1700: Regular expression inline flags incorrectly handle certain
+ unicode characters.
+
- Change ctypes version number to 1.0.3 (when Python 2.5.2 is released,
ctypes 1.0.3 will be also be released).
More information about the Python-checkins
mailing list