Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 77f6ccd

Browse files
committed
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.
1 parent 9e4e050 commit 77f6ccd

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

Tools/idle/ReplaceDialog.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import tkMessageBox
77
import SearchEngine
88
from SearchDialogBase import SearchDialogBase
9+
import sre_parse
910

1011
def replace(text):
1112
root = text._root()
@@ -158,17 +159,9 @@ def _expand(self, m, template):
158159
# XXX This code depends on internals of the regular expression
159160
# engine! There's no standard API to do a substitution when you
160161
# have already found the match. One should be added.
161-
# The solution here is designed to be backwards compatible
162-
# with previous Python versions, e.g. 1.5.2.
163-
# XXX This dynamic test should be done only once.
164-
if getattr(re, "engine", "pre") == "pre":
165-
return re.pcre_expand(m, template)
166-
else: # sre
167-
# XXX This import should be avoidable...
168-
import sre_parse
169-
# XXX This parses the template over and over...
170-
ptemplate = sre_parse.parse_template(template, m.re)
171-
return sre_parse.expand_template(ptemplate, m)
162+
# XXX This parses the template over and over...
163+
ptemplate = sre_parse.parse_template(template, m.re)
164+
return sre_parse.expand_template(ptemplate, m)
172165

173166
def show_hit(self, first, last):
174167
text = self.text

0 commit comments

Comments
 (0)