# Buggy code
def virtualenv_ver(venv_bin, user=None, **kwargs):
    """
    return virtualenv version if exists
    """
    # Virtualenv package
    try:
        import virtualenv

        version = getattr(virtualenv, "__version__", None)
        if not version:
            version = virtualenv.virtualenv_version
        virtualenv_version_info = tuple(
            [int(i) for i in version.split("rc")[0].split(".")]
        )
    except ImportError:
        # Unable to import?? Let's parse the version from the console
        version_cmd = [venv_bin, "--version"]
        ret = __salt__["cmd.run_all"](
            version_cmd, runas=user, python_shell=False, redirect_stderr=True, **kwargs
        )
        if ret["retcode"] > 0 or not ret["stdout"].strip():
            raise CommandExecutionError(
                "Unable to get the virtualenv version output using '{0}'. "
                "Returned data: {1}".format(version_cmd, ret)
            )
        # 20.0.0 virtualenv changed the --version output. find version number
        ver = "".join(
            [x for x in ret["stdout"].strip().split() if re.search(r"^\d.\d*", x)]
        )
        virtualenv_version_info = tuple([int(i) for i in ver.split("rc")[0].split(".")])
    return virtualenv_version_info


# Traceback (ValueError)
======================================================================
ERROR: test_thin_dir (unit.utils.test_thin.SSHThinTestCase)
[CPU:0.0%|MEM:69.8%] Test the thin dir to make sure salt-call can run
----------------------------------------------------------------------
Traceback (most recent call last):
File "/<<PKGBUILDDIR>>/tests/unit/utils/test_thin.py", line 1312, in test_thin_dir
with VirtualEnv() as venv:
File "/<<PKGBUILDDIR>>/tests/support/helpers.py", line 1659, in __enter__
self._create_virtualenv()
File "/<<PKGBUILDDIR>>/tests/support/helpers.py", line 1718, in _create_virtualenv
sminion.functions.virtualenv.create(
File "/<<PKGBUILDDIR>>/salt/modules/virtualenv_mod.py", line 204, in create
virtualenv_version_info = virtualenv_ver(venv_bin, user=user, **kwargs)
File "/<<PKGBUILDDIR>>/salt/modules/virtualenv_mod.py", line 60, in virtualenv_ver
[int(i) for i in version.split("rc")[0].split(".")]
File "/<<PKGBUILDDIR>>/salt/modules/virtualenv_mod.py", line 60, in <listcomp>
[int(i) for i in version.split("rc")[0].split(".")]
ValueError: invalid literal for int() with base 10: '23+ds'

----------------------------------------------------------------------

# Fixed code
def virtualenv_ver(venv_bin, user=None, **kwargs):
    """
    return virtualenv version if exists
    """
    # Virtualenv package
    try:
        import virtualenv

        version = getattr(virtualenv, "__version__", None)
        if not version:
            version = virtualenv.virtualenv_version
    except ImportError:
        # Unable to import?? Let's parse the version from the console
        version_cmd = [venv_bin, "--version"]
        ret = __salt__["cmd.run_all"](
            version_cmd, runas=user, python_shell=False, redirect_stderr=True, **kwargs
        )
        if ret["retcode"] > 0 or not ret["stdout"].strip():
            raise CommandExecutionError(
                "Unable to get the virtualenv version output using '{0}'. "
                "Returned data: {1}".format(version_cmd, ret)
            )
        # 20.0.0 virtualenv changed the --version output. find version number
        version = "".join(
            [x for x in ret["stdout"].strip().split() if re.search(r"^\d.\d*", x)]
        )
    virtualenv_version_info = tuple(
        [int(i) for i in re.sub(r"(rc|\+ds).*$", "", version).split(".")]
    )
    return virtualenv_version_info