Commit 77f6ccd1 authored by Guido van Rossum's avatar Guido van Rossum

The test for re.engine was misfiring because re.engine is no longer

defined and the default was "pre" instead of "sre".  Give up on 1.5.2
compatibility, hardcode the sre solution.  However, this XXX comment
still applies, AFAIK:
        # XXX This code depends on internals of the regular expression
        # engine!  There's no standard API to do a substitution when you
        # have already found the match.  One should be added.
parent 9e4e050c
...@@ -6,6 +6,7 @@ from Tkinter import * ...@@ -6,6 +6,7 @@ from Tkinter import *
import tkMessageBox import tkMessageBox
import SearchEngine import SearchEngine
from SearchDialogBase import SearchDialogBase from SearchDialogBase import SearchDialogBase
import sre_parse
def replace(text): def replace(text):
root = text._root() root = text._root()
...@@ -158,17 +159,9 @@ class ReplaceDialog(SearchDialogBase): ...@@ -158,17 +159,9 @@ class ReplaceDialog(SearchDialogBase):
# XXX This code depends on internals of the regular expression # XXX This code depends on internals of the regular expression
# engine! There's no standard API to do a substitution when you # engine! There's no standard API to do a substitution when you
# have already found the match. One should be added. # have already found the match. One should be added.
# The solution here is designed to be backwards compatible # XXX This parses the template over and over...
# with previous Python versions, e.g. 1.5.2. ptemplate = sre_parse.parse_template(template, m.re)
# XXX This dynamic test should be done only once. return sre_parse.expand_template(ptemplate, m)
if getattr(re, "engine", "pre") == "pre":
return re.pcre_expand(m, template)
else: # sre
# XXX This import should be avoidable...
import sre_parse
# XXX This parses the template over and over...
ptemplate = sre_parse.parse_template(template, m.re)
return sre_parse.expand_template(ptemplate, m)
def show_hit(self, first, last): def show_hit(self, first, last):
text = self.text text = self.text
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment