Comment 2 for bug 653180

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