]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport effbot's checkin of
authorMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:34:08 +0000 (16:34 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:34:08 +0000 (16:34 +0000)
    revision 1.13 of pre.py

Fix bug #570057: Broken pre.subn() (and pre.sub())

This should be backported to the 2.2.X series (how
do I do that?)

Lib/pre.py

index 1665660bd8afb1d3df3e1a1fe50f28d625af44a3..7d5e85cf17c9f0551fc2cfdefe7cf0234f6726cc 100644 (file)
@@ -361,10 +361,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: