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

Eric S. Raymond esr@users.sourceforge.net
Fri, 09 Feb 2001 03:36:18 -0800


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

Modified Files:
	sre_parse.py 
Log Message:
String method conversion.


Index: sre_parse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** sre_parse.py	2001/01/16 07:37:30	1.41
--- sre_parse.py	2001/02/09 11:36:16	1.42
***************
*** 11,15 ****
  # XXX: show string offset and offending character for all errors
  
! import string, sys
  
  from sre_constants import *
--- 11,15 ----
  # XXX: show string offset and offending character for all errors
  
! import sys
  
  from sre_constants import *
***************
*** 61,70 ****
  }
  
- try:
-     int("10", 8)
-     atoi = int
- except TypeError:
-     atoi = string.atoi
- 
  class Pattern:
      # master pattern object.  keeps track of global attributes
--- 61,64 ----
***************
*** 223,227 ****
      # check if the escape string represents a valid group
      try:
!         gid = atoi(escape[1:])
          if gid and gid < groups:
              return gid
--- 217,221 ----
      # check if the escape string represents a valid group
      try:
!         gid = int(escape[1:])
          if gid and gid < groups:
              return gid
***************
*** 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)
--- 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)
***************
*** 252,256 ****
                  escape = escape + source.get()
              escape = escape[1:]
!             return LITERAL, atoi(escape, 8) & 0xff
          if len(escape) == 2:
              return LITERAL, ord(escape[1])
--- 246,250 ----
                  escape = escape + source.get()
              escape = escape[1:]
!             return LITERAL, int(escape, 8) & 0xff
          if len(escape) == 2:
              return LITERAL, ord(escape[1])
***************
*** 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)
--- 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)
***************
*** 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)
--- 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)
***************
*** 463,469 ****
                      continue
                  if lo:
!                     min = atoi(lo)
                  if hi:
!                     max = atoi(hi)
                  if max < min:
                      raise error, "bad repeat interval"
--- 457,463 ----
                      continue
                  if lo:
!                     min = int(lo)
                  if hi:
!                     max = int(hi)
                  if max < min:
                      raise error, "bad repeat interval"
***************
*** 653,657 ****
                      raise error, "bad group name"
                  try:
!                     index = atoi(name)
                  except ValueError:
                      if not isname(name):
--- 647,651 ----
                      raise error, "bad group name"
                  try:
!                     index = int(name)
                  except ValueError:
                      if not isname(name):
***************
*** 677,681 ****
                  if not code:
                      this = this[1:]
!                     code = LITERAL, atoi(this[-6:], 8) & 0xff
                  a(code)
              else:
--- 671,675 ----
                  if not code:
                      this = this[1:]
!                     code = LITERAL, int(this[-6:], 8) & 0xff
                  a(code)
              else:
***************
*** 706,708 ****
                  raise error, "empty group"
              a(s)
!     return string.join(p, sep)
--- 700,702 ----
                  raise error, "empty group"
              a(s)
!     return sep.join(p)