[pypy-svn] pypy default: use "?" instead of the empty string when the hg information cannot be retrieved, else platform.py cannot parse sys.version
antocuni
commits-noreply at bitbucket.org
Tue Jan 18 13:02:44 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r40839:3b8bd9907b28
Date: 2011-01-18 13:01 +0100
http://bitbucket.org/pypy/pypy/changeset/3b8bd9907b28/
Log: use "?" instead of the empty string when the hg information cannot
be retrieved, else platform.py cannot parse sys.version
diff --git a/pypy/tool/test/test_version.py b/pypy/tool/test/test_version.py
--- a/pypy/tool/test/test_version.py
+++ b/pypy/tool/test/test_version.py
@@ -3,7 +3,6 @@
from pypy.tool.version import get_mercurial_info
def test_get_mercurial_info():
- assert get_mercurial_info(py.path.local.sysfind(
- 'completely broken mercurial'))
- assert get_mercurial_info(os.devnull)
- assert get_mercurial_info(sys.executable)
+ assert get_mercurial_info(None)
+ assert get_mercurial_info(os.devnull) == ('PyPy', '?', '?')
+ assert get_mercurial_info(sys.executable) == ('PyPy', '?', '?')
diff --git a/pypy/tool/version.py b/pypy/tool/version.py
--- a/pypy/tool/version.py
+++ b/pypy/tool/version.py
@@ -8,6 +8,7 @@
'''Obtain Mercurial version information by invoking the 'hg' command.'''
# TODO: support extracting from .hg_archival.txt
+ default_retval = 'PyPy', '?', '?'
pypyroot = os.path.abspath(os.path.join(pypydir, '..'))
if hgexe is None:
hgexe = py.path.local.sysfind('hg')
@@ -23,10 +24,10 @@
if not os.path.isdir(os.path.join(pypyroot, '.hg')):
maywarn('Not running from a Mercurial repository!')
- return 'PyPy', '', ''
+ return default_retval
elif not hgexe:
maywarn('Cannot find Mercurial command!')
- return 'PyPy', '', ''
+ return default_retval
else:
env = dict(os.environ)
# get Mercurial into scripting mode
@@ -39,11 +40,11 @@
stdout=PIPE, stderr=PIPE, env=env)
except OSError, e:
maywarn(e)
- return 'PyPy', '', ''
+ return default_retval
if not p.stdout.read().startswith('Mercurial Distributed SCM'):
maywarn('command does not identify itself as Mercurial')
- return 'PyPy', '', ''
+ return default_retval
p = Popen([str(hgexe), 'id', '-i', pypyroot],
stdout=PIPE, stderr=PIPE, env=env)
More information about the Pypy-commit
mailing list