# Buggy code
def basepython_default(testenv_config, value):
    """either user set or proposed from the factor name

    in both cases we check that the factor name implied python version and the resolved
    python interpreter version match up; if they don't we warn, unless ignore base
    python conflict is set in which case the factor name implied version if forced
    """
    for factor in testenv_config.factors:
        if factor in tox.PYTHON.DEFAULT_FACTORS:
            implied_python = tox.PYTHON.DEFAULT_FACTORS[factor]
            break
    else:
        implied_python, factor = None, None

    if testenv_config.config.ignore_basepython_conflict and implied_python is not None:
        return implied_python

    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
                    )
                )
    return proposed_python


# Traceback (TypeError)
ci\appveyor\build.cmd py -3.5 -m tox
Using default MSVC build environment
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 27) for env 'py27-test-deps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 27) for env 'py27-test-mindeps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 34) for env 'py34-test-deps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 34) for env 'py34-test-mindeps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 35) for env 'py35-test-deps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 35) for env 'py35-test-mindeps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 37) for env 'py37-test-deps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
C:\Python35-x64\lib\site-packages\tox\config\__init__.py:576: UserWarning: conflicting basepython version (set 36, should be 37) for env 'py37-test-mindeps';resolve conflict or set ignore_basepython_conflict
proposed_version, implied_version, testenv_config.envname
Traceback (most recent call last):
File "C:\Python35-x64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python35-x64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python35-x64\lib\site-packages\tox\__main__.py", line 4, in <module>
tox.cmdline()
File "C:\Python35-x64\lib\site-packages\tox\session\__init__.py", line 42, in cmdline
main(args)
File "C:\Python35-x64\lib\site-packages\tox\session\__init__.py", line 58, in main
config = load_config(args)
File "C:\Python35-x64\lib\site-packages\tox\session\__init__.py", line 75, in load_config
config = parseconfig(args)
File "C:\Python35-x64\lib\site-packages\tox\config\__init__.py", line 249, in parseconfig
ParseIni(config, config_file, content)
File "C:\Python35-x64\lib\site-packages\tox\config\__init__.py", line 1077, in __init__
config.envconfigs[name] = self.make_envconfig(name, section, reader._subs, config)
File "C:\Python35-x64\lib\site-packages\tox\config\__init__.py", line 1181, in make_envconfig
res = env_attr.postprocess(testenv_config=tc, value=res)
File "C:\Python35-x64\lib\site-packages\tox\config\__init__.py", line 571, in basepython_default
if not proposed_version.startswith(implied_version):
TypeError: startswith first arg must be str or a tuple of str, not NoneType

# Fixed code
def basepython_default(testenv_config, value):
    """either user set or proposed from the factor name

    in both cases we check that the factor name implied python version and the resolved
    python interpreter version match up; if they don't we warn, unless ignore base
    python conflict is set in which case the factor name implied version if forced
    """
    for factor in testenv_config.factors:
        if factor in tox.PYTHON.DEFAULT_FACTORS:
            implied_python = tox.PYTHON.DEFAULT_FACTORS[factor]
            break
    else:
        implied_python, factor = None, None

    if testenv_config.config.ignore_basepython_conflict and implied_python is not None:
        return implied_python

    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
        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