@@ -561,21 +561,23 @@ def basepython_default(testenv_config, value):
561
561
proposed_python = (implied_python or sys .executable ) if value is None else str (value )
562
562
if implied_python is not None and implied_python != proposed_python :
563
563
testenv_config .basepython = proposed_python
564
- implied_version = tox .PYTHON .PY_FACTORS_RE .match (factor ).group (2 )
565
- python_info_for_proposed = testenv_config .python_info
566
- if not isinstance (python_info_for_proposed , NoInterpreterInfo ):
567
- proposed_version = "" .join (
568
- str (i ) for i in python_info_for_proposed .version_info [0 :2 ]
569
- )
570
- # '27'.startswith('2') or '27'.startswith('27')
571
- if not proposed_version .startswith (implied_version ):
572
- # TODO(stephenfin): Raise an exception here in tox 4.0
573
- warnings .warn (
574
- "conflicting basepython version (set {}, should be {}) for env '{}';"
575
- "resolve conflict or set ignore_basepython_conflict" .format (
576
- proposed_version , implied_version , testenv_config .envname
577
- )
564
+ match = tox .PYTHON .PY_FACTORS_RE .match (factor )
565
+ implied_version = match .group (2 ) if match else None
566
+ if implied_version is not None :
567
+ python_info_for_proposed = testenv_config .python_info
568
+ if not isinstance (python_info_for_proposed , NoInterpreterInfo ):
569
+ proposed_version = "" .join (
570
+ str (i ) for i in python_info_for_proposed .version_info [0 :2 ]
578
571
)
572
+ # '27'.startswith('2') or '27'.startswith('27')
573
+ if not proposed_version .startswith (implied_version ):
574
+ # TODO(stephenfin): Raise an exception here in tox 4.0
575
+ warnings .warn (
576
+ "conflicting basepython version (set {}, should be {}) for env '{}';"
577
+ "resolve conflict or set ignore_basepython_conflict" .format (
578
+ proposed_version , implied_version , testenv_config .envname
579
+ )
580
+ )
579
581
return proposed_python
580
582
581
583
parser .add_testenv_attribute (
0 commit comments