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

Fredrik Lundh effbot@users.sourceforge.net
Mon, 15 Jan 2001 23:37:32 -0800


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

Modified Files:
	sre.py sre_parse.py 
Log Message:


bumped SRE version number to 2.1.  cleaned up and added 1.5.2
compatibility patches.

Index: sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** sre.py	2001/01/14 15:06:11	1.26
--- sre.py	2001/01/16 07:37:30	1.27
***************
*** 182,186 ****
          append(string[i:b])
          if g and b != e:
!             extend(m.groups())
          i = e
          n = n + 1
--- 182,186 ----
          append(string[i:b])
          if g and b != e:
!             extend(list(m.groups()))
          i = e
          n = n + 1

Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** sre_parse.py	2001/01/14 21:00:44	1.40
--- sre_parse.py	2001/01/16 07:37:30	1.41
***************
*** 61,64 ****
--- 61,70 ----
  }
  
+ try:
+     int("10", 8)
+     atoi = int
+ except TypeError:
+     atoi = string.atoi
+ 
  class Pattern:
      # master pattern object.  keeps track of global attributes
***************
*** 217,221 ****
      # check if the escape string represents a valid group
      try:
!         gid = int(escape[1:])
          if gid and gid < groups:
              return gid
--- 223,227 ----
      # check if the escape string represents a valid group
      try:
!         gid = atoi(escape[1:])
          if gid and gid < groups:
              return gid
***************
*** 240,244 ****
              if len(escape) != 2:
                  raise error, "bogus escape: %s" % repr("\\" + escape)
!             return LITERAL, int(escape, 16) & 0xff
          elif str(escape[1:2]) in OCTDIGITS:
              # octal escape (up to three digits)
--- 246,250 ----
              if len(escape) != 2:
                  raise error, "bogus escape: %s" % repr("\\" + escape)
!             return LITERAL, atoi(escape, 16) & 0xff
          elif str(escape[1:2]) in OCTDIGITS:
              # octal escape (up to three digits)
***************
*** 246,250 ****
                  escape = escape + source.get()
              escape = escape[1:]
!             return LITERAL, int(escape, 8) & 0xff
          if len(escape) == 2:
              return LITERAL, ord(escape[1])
--- 252,256 ----
                  escape = escape + source.get()
              escape = escape[1:]
!             return LITERAL, atoi(escape, 8) & 0xff
          if len(escape) == 2:
              return LITERAL, ord(escape[1])
***************
*** 268,277 ****
              if len(escape) != 4:
                  raise ValueError
!             return LITERAL, int(escape[2:], 16) & 0xff
          elif escape[1:2] == "0":
              # octal escape
              while source.next in OCTDIGITS and len(escape) < 4:
                  escape = escape + source.get()
!             return LITERAL, int(escape[1:], 8) & 0xff
          elif escape[1:2] in DIGITS:
              # octal escape *or* decimal group reference (sigh)
--- 274,283 ----
              if len(escape) != 4:
                  raise ValueError
!             return LITERAL, atoi(escape[2:], 16) & 0xff
          elif escape[1:2] == "0":
              # octal escape
              while source.next in OCTDIGITS and len(escape) < 4:
                  escape = escape + source.get()
!             return LITERAL, atoi(escape[1:], 8) & 0xff
          elif escape[1:2] in DIGITS:
              # octal escape *or* decimal group reference (sigh)
***************
*** 283,287 ****
                      # got three octal digits; this is an octal escape
                      escape = escape + source.get()
!                     return LITERAL, int(escape[1:], 8) & 0xff
              # got at least one decimal digit; this is a group reference
              group = _group(escape, state.groups)
--- 289,293 ----
                      # got three octal digits; this is an octal escape
                      escape = escape + source.get()
!                     return LITERAL, atoi(escape[1:], 8) & 0xff
              # got at least one decimal digit; this is a group reference
              group = _group(escape, state.groups)
***************
*** 457,463 ****
                      continue
                  if lo:
!                     min = int(lo)
                  if hi:
!                     max = int(hi)
                  if max < min:
                      raise error, "bad repeat interval"
--- 463,469 ----
                      continue
                  if lo:
!                     min = atoi(lo)
                  if hi:
!                     max = atoi(hi)
                  if max < min:
                      raise error, "bad repeat interval"
***************
*** 647,651 ****
                      raise error, "bad group name"
                  try:
!                     index = int(name)
                  except ValueError:
                      if not isname(name):
--- 653,657 ----
                      raise error, "bad group name"
                  try:
!                     index = atoi(name)
                  except ValueError:
                      if not isname(name):
***************
*** 663,667 ****
                          if (s.next not in DIGITS or
                              not _group(this + s.next, pattern.groups+1)):
!                             code = MARK, int(group)
                              break
                      elif s.next in OCTDIGITS:
--- 669,673 ----
                          if (s.next not in DIGITS or
                              not _group(this + s.next, pattern.groups+1)):
!                             code = MARK, group
                              break
                      elif s.next in OCTDIGITS:
***************
*** 671,675 ****
                  if not code:
                      this = this[1:]
!                     code = LITERAL, int(this[-6:], 8) & 0xff
                  a(code)
              else:
--- 677,681 ----
                  if not code:
                      this = this[1:]
!                     code = LITERAL, atoi(this[-6:], 8) & 0xff
                  a(code)
              else: