diff options
author | Guido van Rossum <guido@python.org> | 2002-07-24 01:49:16 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-07-24 01:49:16 (GMT) |
commit | 77f6ccd1f7a692d3701797d79f36113d9a94c717 (patch) | |
tree | 92f871f732aa8c1dca761f86394c1fc539c7a523 /Tools | |
parent | 9e4e050c594cc6b56d683267b97b339a274bb31c (diff) | |
download | cpython-77f6ccd1f7a692d3701797d79f36113d9a94c717.zip cpython-77f6ccd1f7a692d3701797d79f36113d9a94c717.tar.gz cpython-77f6ccd1f7a692d3701797d79f36113d9a94c717.tar.bz2 |
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.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/idle/ReplaceDialog.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Tools/idle/ReplaceDialog.py b/Tools/idle/ReplaceDialog.py index 1e46f36..7d5de69 100644 --- a/Tools/idle/ReplaceDialog.py +++ b/Tools/idle/ReplaceDialog.py @@ -6,6 +6,7 @@ from Tkinter import * import tkMessageBox import SearchEngine from SearchDialogBase import SearchDialogBase +import sre_parse def replace(text): root = text._root() @@ -158,17 +159,9 @@ class ReplaceDialog(SearchDialogBase): # 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. - # The solution here is designed to be backwards compatible - # with previous Python versions, e.g. 1.5.2. - # XXX This dynamic test should be done only once. - 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) + # 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): text = self.text |