fails to parse python's version number from "2.7.0+"

Bug #653180 reported by Marius Gedminas
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Buildout
New
Undecided
Unassigned

Bug Description

The python2.7 package currently available in Debian experimental patches PY_VERSION to say "2.7.0+". This makes 'python2.7 -V' print "Python 2.7.0+", and that makes zc.buildout crash:

    mg@platonas:~/src/zope.testing $ bin/buildout install test24 test25 test26 test27
    Develop: '/home/mg/src/zope.testing/.'
    warning: no files found matching '*.test' under directory 'src'
    warning: no files found matching 'sampletests' under directory 'src'
    Installing test24.
    Generated script '/home/mg/src/zope.testing/bin/test24'.
    Installing test25.
    Generated script '/home/mg/src/zope.testing/bin/test25'.
    Installing test26.
    Generated script '/home/mg/src/zope.testing/bin/test26'.
    Installing test27.
    While:
      Installing test27.

    An internal error occurred due to a bug in either zc.buildout or in a
    recipe being used:
    Traceback (most recent call last):
      File "/home/mg/.buildout/eggs/zc.buildout-1.5.1-py2.6.egg/zc/buildout/buildout.py", line 1784, in main
        getattr(buildout, command)(args)
      File "/home/mg/.buildout/eggs/zc.buildout-1.5.1-py2.6.egg/zc/buildout/buildout.py", line 569, in install
        installed_files = self[part]._call(recipe.install)
      File "/home/mg/.buildout/eggs/zc.buildout-1.5.1-py2.6.egg/zc/buildout/buildout.py", line 1276, in _call
        return f()
      File "/home/mg/.buildout/eggs/zc.recipe.testrunner-1.4.0-py2.6.egg/zc/recipe/testrunner/__init__.py", line 46, in install
        eggs, ws = self._delegated.working_set(('zope.testrunner', ))
      File "/home/mg/.buildout/eggs/zc.recipe.egg-1.3.2-py2.6.egg/zc/recipe/egg/egg.py", line 101, in working_set
        **kw)
      File "/home/mg/.buildout/eggs/zc.buildout-1.5.1-py2.6.egg/zc/buildout/easy_install.py", line 1089, in install
        prefer_final=prefer_final)
      File "/home/mg/.buildout/eggs/zc.buildout-1.5.1-py2.6.egg/zc/buildout/easy_install.py", line 399, in __init__
        python=_get_version(executable))
      File "/home/mg/.buildout/eggs/zc.buildout-1.5.1-py2.6.egg/zc/buildout/easy_install.py", line 191, in _get_version
        version = re.match('(\d[.]\d)([.].*\d)?$', version).group(1)
    AttributeError: 'NoneType' object has no attribute 'group'

Ubuntu is also affected: both the python2.7 package in Maverick, and the backports for older releases that are available in the popular ~fkrull/deadsnakes PPA, have the same weird version string.

The following workaround fixes the issue for me:

    Index: src/zc/buildout/easy_install.py
    ===================================================================
    --- src/zc/buildout/easy_install.py (revision 117136)
    +++ src/zc/buildout/easy_install.py (working copy)
    @@ -188,7 +188,7 @@ def _get_version(executable):
             o.close()
             pystring, version = version.split()
             assert pystring == 'Python'
    - version = re.match('(\d[.]\d)([.].*\d)?$', version).group(1)
    + version = re.match('(\d[.]\d)([.].*\d)?[+]?$', version).group(1)
             _versions[executable] = version
             return version

Revision history for this message
Bruno Clermont (b.clermont-deactivatedaccount) wrote :

Ubuntu Natty Python version is 2.7.1+

which cause the same issue.

IMHO, there should not be a '+' char in python version string...

Revision history for this message
Grzegorz Gutowski (grzegorz-gutowski) wrote :

sys.version
A string containing the version number of the Python interpreter plus additional information on the build number and compiler used. This string is displayed when the interactive interpreter is started. Do not extract version information out of it, rather, use version_info and the functions provided by the platform module.

How about changing _get_version to use sys.version_info? It is available since Python 2.0
This workaround works for me:

  def _get_version(executable):
      try:
          return _versions[executable]
      except KeyError:
          stdout, stderr = subprocess.Popen(
              [executable, '-Sc',
               'import sys\n'
               'print \'%d.%d\' % sys.version_info[:2]\n'
               ],
          stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
          _versions[executable] = stdout.strip()
          return version

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.