[Python-3000-checkins] r66365 - in python/branches/py3k: Lib/test/test_re.py Modules/_sre.c

guido.van.rossum python-3000-checkins at python.org
Wed Sep 10 16:30:50 CEST 2008


Author: guido.van.rossum
Date: Wed Sep 10 16:30:50 2008
New Revision: 66365

Log:
Merged revisions 66364 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66364 | guido.van.rossum | 2008-09-10 07:27:00 -0700 (Wed, 10 Sep 2008) | 3 lines
  
  Issue #3751: str.rpartition would perform a left-partition when called with
  a unicode argument.  Reviewed by Amaury.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/test/test_re.py
   python/branches/py3k/Modules/_sre.c

Modified: python/branches/py3k/Lib/test/test_re.py
==============================================================================
--- python/branches/py3k/Lib/test/test_re.py	(original)
+++ python/branches/py3k/Lib/test/test_re.py	Wed Sep 10 16:30:50 2008
@@ -91,6 +91,10 @@
         self.assertRaises(ValueError, re.findall, pattern, 'A', re.I)
         self.assertRaises(ValueError, re.compile, pattern, re.I)
 
+    def test_bug_3629(self):
+        # A regex that triggered a bug in the sre-code validator
+        re.compile("(?P<quote>)(?(quote))")
+
     def test_sub_template_numeric_escape(self):
         # bug 776311 and friends
         self.assertEqual(re.sub('x', r'\0', 'x'), '\0')

Modified: python/branches/py3k/Modules/_sre.c
==============================================================================
--- python/branches/py3k/Modules/_sre.c	(original)
+++ python/branches/py3k/Modules/_sre.c	Wed Sep 10 16:30:50 2008
@@ -2780,17 +2780,18 @@
         arg = *code++;                                  \
         VTRACE(("%lu (arg)\n", (unsigned long)arg));    \
     } while (0)
-#define GET_SKIP                                        \
+#define GET_SKIP_ADJ(adj)                               \
     do {                                                \
         VTRACE(("%p= ", code));                         \
         if (code >= end) FAIL;                          \
         skip = *code;                                   \
         VTRACE(("%lu (skip to %p)\n",                   \
                (unsigned long)skip, code+skip));        \
-        if (code+skip < code || code+skip > end)        \
+        if (code+skip-adj < code || code+skip-adj > end)\
             FAIL;                                       \
         code++;                                         \
     } while (0)
+#define GET_SKIP GET_SKIP_ADJ(0)
 
 static int
 _validate_charset(SRE_CODE *code, SRE_CODE *end)
@@ -3097,7 +3098,7 @@
             GET_ARG;
             if (arg >= groups)
                 FAIL;
-            GET_SKIP;
+            GET_SKIP_ADJ(1);
             code--; /* The skip is relative to the first arg! */
             /* There are two possibilities here: if there is both a 'then'
                part and an 'else' part, the generated code looks like:


More information about the Python-3000-checkins mailing list