[Python-Dev] Problem in SRE ? (original) (raw)

M.-A. Lemburg mal@lemburg.com
Wed, 07 Nov 2001 16:25:18 +0100


I've just run across a strange problem with SRE. The following code does not run with the current CVS version -- the program simply exists without notice even though there doesn't seem to be an exit() or abort() call in SRE.

Note that sys.version is '2.2b1+ (#59, Nov 7 2001, 12:57:29) \n[GCC pgcc-2.95.2 19991024 (release)]'

Any ideas ?

-- import sys, re, string sys_version_parser = re.compile('([\w.]+)\s*' '(#(\d+),\s*([\w ]+),\s*([\w :]+))\s*'_ '[([^]]+)]?') _sys_version_cache = None

def _sys_version():

 """ Returns a parsed version of Python's sys.version as tuple
     (version, buildno, builddate, compiler) referring to the Python
     version, build number, build date/time as string and the

compiler identification string.

     Note that unlike the Python sys.version, the returned value
     for the Python version will always include the patchlevel (it
     defaults to '.0').

 """
 global _sys_version_cache
 import sys, re, time

 if _sys_version_cache is not None:
     return _sys_version_cache
 print sys.version
 version, buildno, builddate, buildtime, compiler = \
          _sys_version_parser.match(sys.version).groups()
 buildno = int(buildno)
 builddate = builddate + ' ' + buildtime
 l = string.split(version, '.')
 if len(l) == 2:
     l.append('0')
     version = string.join(l, '.')
 _sys_version_cache = (version, buildno, builddate, compiler)
 return _sys_version_cache

-- Marc-Andre Lemburg CEO eGenix.com Software GmbH


Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/