[Python-checkins] CVS: python/dist/src/Lib sre.py,1.40,1.41

Fredrik Lundh effbot@users.sourceforge.net
Sun, 21 Oct 2001 11:04:13 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv30794/Lib

Modified Files:
	sre.py 
Log Message:


sre.Scanner fixes (from Greg Chapman).  also added a Scanner sanity
check to the test suite.

added a few missing exception checks in the _sre module
 

Index: sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** sre.py	2001/10/21 16:47:57	1.40
--- sre.py	2001/10/21 18:04:11	1.41
***************
*** 331,335 ****
  
  class Scanner:
!     def __init__(self, lexicon):
          from sre_constants import BRANCH, SUBPATTERN
          self.lexicon = lexicon
--- 331,335 ----
  
  class Scanner:
!     def __init__(self, lexicon, flags=0):
          from sre_constants import BRANCH, SUBPATTERN
          self.lexicon = lexicon
***************
*** 337,343 ****
          p = []
          s = sre_parse.Pattern()
          for phrase, action in lexicon:
              p.append(sre_parse.SubPattern(s, [
!                 (SUBPATTERN, (len(p), sre_parse.parse(phrase))),
                  ]))
          p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
--- 337,344 ----
          p = []
          s = sre_parse.Pattern()
+         s.flags = flags
          for phrase, action in lexicon:
              p.append(sre_parse.SubPattern(s, [
!                 (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))),
                  ]))
          p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
***************
*** 347,354 ****
          result = []
          append = result.append
!         match = self.scanner.match
          i = 0
          while 1:
!             m = match(string, i)
              if not m:
                  break
--- 348,355 ----
          result = []
          append = result.append
!         match = self.scanner.scanner(string).match
          i = 0
          while 1:
!             m = match()
              if not m:
                  break
***************
*** 356,360 ****
              if i == j:
                  break
!             action = self.lexicon[m.lastindex][1]
              if callable(action):
                  self.match = m
--- 357,361 ----
              if i == j:
                  break
!             action = self.lexicon[m.lastindex-1][1]
              if callable(action):
                  self.match = m