[Python-checkins] python/dist/src/Tools/idle ReplaceDialog.py,1.4,1.4.24.1

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
2002年9月23日 07:37:03 -0700


Update of /cvsroot/python/python/dist/src/Tools/idle
In directory usw-pr-cvs1:/tmp/cvs-serv12716
Modified Files:
 Tag: release22-maint
	ReplaceDialog.py 
Log Message:
Backport:
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.
Index: ReplaceDialog.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/ReplaceDialog.py,v
retrieving revision 1.4
retrieving revision 1.4.24.1
diff -C2 -d -r1.4 -r1.4.24.1
*** ReplaceDialog.py	19 Sep 2000 20:51:17 -0000	1.4
--- ReplaceDialog.py	23 Sep 2002 14:37:00 -0000	1.4.24.1
***************
*** 7,10 ****
--- 7,11 ----
 import SearchEngine
 from SearchDialogBase import SearchDialogBase
+ import sre_parse
 
 def replace(text):
***************
*** 159,173 ****
 # 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)
 
 def show_hit(self, first, last):
--- 160,166 ----
 # engine! There's no standard API to do a substitution when you
 # have already found the match. One should be added.
! # 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):

AltStyle によって変換されたページ (->オリジナル) /