# Buggy code
def ensure_project(
    three=None,
    python=None,
    validate=True,
    system=False,
    warn=True,
    site_packages=False,
    deploy=False,
    skip_requirements=False,
):
    """Ensures both Pipfile and virtualenv exist for the project."""

    # Automatically use an activated virtualenv.
    if PIPENV_USE_SYSTEM:
        system = True

    if not project.pipfile_exists:
        project.touch_pipfile()

    # Skip virtualenv creation when --system was used.
    if not system:
        ensure_virtualenv(three=three, python=python, site_packages=site_packages)

        if warn:
            # Warn users if they are using the wrong version of Python.
            if project.required_python_version:
                path_to_python = which("python")

                if project.required_python_version not in (
                    python_version(path_to_python) or ""
                ):
                    click.echo(
                        "{0}: Your Pipfile requires {1} {2}, "
                        "but you are using {3} ({4}).".format(
                            crayons.red("Warning", bold=True),
                            crayons.normal("python_version", bold=True),
                            crayons.blue(project.required_python_version),
                            crayons.blue(python_version(path_to_python)),
                            crayons.green(shorten_path(path_to_python)),
                        ),
                        err=True,
                    )
                    if not deploy:
                        click.echo(
                            "  {0} will surely fail.".format(
                                crayons.red("$ pipenv check")
                            ),
                            err=True,
                        )
                    else:
                        click.echo(crayons.red("Deploy aborted."), err=True)
                        sys.exit(1)

    # Ensure the Pipfile exists.
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements)


# Traceback (AttributeError)
py -3 -m pipenv --python C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe
Creating a virtualenv for this project…
Using C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe to create virtualenv…
Already using interpreter C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe
Using base prefix 'C:\\Users\\brcan\\AppData\\Local\\Programs\\Python\\Python36'
New python executable in C:\Users\brcan\.virtualenvs\bunk-M_X9FcBv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

Virtualenv location:
Traceback (most recent call last):
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\__main__.py", line 4, in <module>
cli()
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\cli.py", line 154, in cli
core.ensure_project(three=three, python=python, warn=True, site_packages=site_packages)
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\core.py", line 638, in ensure_project
crayons.green(shorten_path(path_to_python))
File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\site-packages\pipenv\core.py", line 698, in shorten_path
short = os.sep.join([s[0] if len(s) > (len('2long4')) else s for s in location.split(os.sep)])
AttributeError: 'NoneType' object has no attribute 'split'

# Fixed code
def ensure_project(
    three=None,
    python=None,
    validate=True,
    system=False,
    warn=True,
    site_packages=False,
    deploy=False,
    skip_requirements=False,
):
    """Ensures both Pipfile and virtualenv exist for the project."""

    # Automatically use an activated virtualenv.
    if PIPENV_USE_SYSTEM:
        system = True

    if not project.pipfile_exists:
        project.touch_pipfile()

    # Skip virtualenv creation when --system was used.
    if not system:
        ensure_virtualenv(three=three, python=python, site_packages=site_packages)

        if warn:
            # Warn users if they are using the wrong version of Python.
            if project.required_python_version:
                path_to_python = which("python")

                if path_to_python and project.required_python_version not in (
                    python_version(path_to_python) or ""
                ):
                    click.echo(
                        "{0}: Your Pipfile requires {1} {2}, "
                        "but you are using {3} ({4}).".format(
                            crayons.red("Warning", bold=True),
                            crayons.normal("python_version", bold=True),
                            crayons.blue(project.required_python_version),
                            crayons.blue(python_version(path_to_python)),
                            crayons.green(shorten_path(path_to_python)),
                        ),
                        err=True,
                    )
                    if not deploy:
                        click.echo(
                            "  {0} will surely fail.".format(
                                crayons.red("$ pipenv check")
                            ),
                            err=True,
                        )
                    else:
                        click.echo(crayons.red("Deploy aborted."), err=True)
                        sys.exit(1)

    # Ensure the Pipfile exists.
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements)