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

Fredrik Lundh effbot@users.sourceforge.net
Thu, 18 Oct 2001 12:30:18 -0700


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

Modified Files:
	sre.py 
Log Message:


SRE bug #441409:
    compile should raise error for non-strings
SRE bug #432570, 448951:
    reset group after failed match

also bumped version number to 2.2.0

Index: sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** sre.py	2001/09/18 20:55:24	1.38
--- sre.py	2001/10/18 19:30:15	1.39
***************
*** 105,109 ****
      "UNICODE", "error" ]
  
! __version__ = "2.1.1"
  
  # this module works under 1.5.2 and later.  don't use string methods
--- 105,109 ----
      "UNICODE", "error" ]
  
! __version__ = "2.2.0"
  
  # this module works under 1.5.2 and later.  don't use string methods
***************
*** 198,201 ****
--- 198,203 ----
  _cache_repl = {}
  
+ _pattern_type = type(sre_compile.compile("", 0))
+ 
  _MAXCACHE = 100
  
***************
*** 210,215 ****
          return p
      pattern, flags = key
!     if type(pattern) not in sre_compile.STRING_TYPES:
          return pattern
      try:
          p = sre_compile.compile(pattern, flags)
--- 212,219 ----
          return p
      pattern, flags = key
!     if type(pattern) is _pattern_type:
          return pattern
+     if type(pattern) not in sre_compile.STRING_TYPES:
+         raise TypeError, "first argument must be string or compiled pattern"
      try:
          p = sre_compile.compile(pattern, flags)
***************
*** 313,317 ****
      return _compile, (p.pattern, p.flags)
  
! copy_reg.pickle(type(_compile("", 0)), _pickle, _compile)
  
  # --------------------------------------------------------------------
--- 317,321 ----
      return _compile, (p.pattern, p.flags)
  
! copy_reg.pickle(_pattern_type, _pickle, _compile)
  
  # --------------------------------------------------------------------