]> granicus.if.org Git - python/commitdiff
Fix bug #570057: Broken pre.subn() (and pre.sub())
authorFredrik Lundh <fredrik@pythonware.com>
Thu, 27 Jun 2002 19:59:27 +0000 (19:59 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Thu, 27 Jun 2002 19:59:27 +0000 (19:59 +0000)
This should be backported to the 2.2.X series (how
do I do that?)

Lib/pre.py

index 504c7c66858fc498bcb72f7d14621179a8a6f180..8bbc1001f04dd0d1096618611ab5d65e4a418cb8 100644 (file)
@@ -367,10 +367,12 @@ class RegexObject:
         end = len(source)
 
         if type(repl) is type(''):
-            # See if repl contains group references
+            # See if repl contains group references (if it does,
+            # pcre_expand will attempt to call _Dummy.group, which
+            # results in a TypeError)
             try:
                 repl = pcre_expand(_Dummy, repl)
-            except error:
+            except (error, TypeError):
                 m = MatchObject(self, source, 0, end, [])
                 repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl)
             else: