diff options
author | Bernát Gábor <gaborjbernat@gmail.com> | 2019-03-29 13:03:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-29 13:03:44 +0000 |
commit | 47476e13e55c3ae8994574d6898fd58a0792dd75 (patch) | |
tree | 9cf888ebe056fb66d9521d9b45e537a38a4b3347 /src | |
parent | 14c0bee732621211611d082ac57cfafa721cbaf9 (diff) | |
download | tox-git-47476e13e55c3ae8994574d6898fd58a0792dd75.tar.gz |
#1227 fix crash when proposed base python has no version data (#1229)
Diffstat (limited to 'src')
-rw-r--r-- | src/tox/config/__init__.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 5380814c..53e4003a 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -561,21 +561,23 @@ def tox_addoption(parser): proposed_python = (implied_python or sys.executable) if value is None else str(value) if implied_python is not None and implied_python != proposed_python: testenv_config.basepython = proposed_python - implied_version = tox.PYTHON.PY_FACTORS_RE.match(factor).group(2) - python_info_for_proposed = testenv_config.python_info - if not isinstance(python_info_for_proposed, NoInterpreterInfo): - proposed_version = "".join( - str(i) for i in python_info_for_proposed.version_info[0:2] - ) - # '27'.startswith('2') or '27'.startswith('27') - if not proposed_version.startswith(implied_version): - # TODO(stephenfin): Raise an exception here in tox 4.0 - warnings.warn( - "conflicting basepython version (set {}, should be {}) for env '{}';" - "resolve conflict or set ignore_basepython_conflict".format( - proposed_version, implied_version, testenv_config.envname - ) + match = tox.PYTHON.PY_FACTORS_RE.match(factor) + implied_version = match.group(2) if match else None + if implied_version is not None: + python_info_for_proposed = testenv_config.python_info + if not isinstance(python_info_for_proposed, NoInterpreterInfo): + proposed_version = "".join( + str(i) for i in python_info_for_proposed.version_info[0:2] ) + # '27'.startswith('2') or '27'.startswith('27') + if not proposed_version.startswith(implied_version): + # TODO(stephenfin): Raise an exception here in tox 4.0 + warnings.warn( + "conflicting basepython version (set {}, should be {}) for env '{}';" + "resolve conflict or set ignore_basepython_conflict".format( + proposed_version, implied_version, testenv_config.envname + ) + ) return proposed_python parser.add_testenv_attribute( |