# Buggy code
def data_scheme_file_maker(zip_file, scheme):
    # type: (ZipFile, Scheme) -> Callable[[RecordPath], File]
    scheme_paths = {}
    for key in SCHEME_KEYS:
        encoded_key = ensure_text(key)
        scheme_paths[encoded_key] = ensure_text(
            getattr(scheme, key), encoding=sys.getfilesystemencoding()
        )

    def make_data_scheme_file(record_path):
        # type: (RecordPath) -> File
        normed_path = os.path.normpath(record_path)
        _, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
        scheme_path = scheme_paths[scheme_key]
        dest_path = os.path.join(scheme_path, dest_subpath)
        assert_no_path_traversal(scheme_path, dest_path)
        return ZipBackedFile(record_path, dest_path, zip_file)

    return make_data_scheme_file


# Traceback (ValueError)
ERROR: Exception:
Traceback (most recent call last):
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 421, in run
pycompile=options.compile,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/req/__init__.py", line 90, in install_given_reqs
pycompile=pycompile,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 831, in install
requested=self.user_supplied,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 830, in install_wheel
requested=requested,
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 658, in _install_wheel
for file in files:
File "/tmp/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 587, in make_data_scheme_file
_, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
ValueError: not enough values to unpack (expected 3, got 2)

# Fixed code
def data_scheme_file_maker(zip_file, scheme):
    # type: (ZipFile, Scheme) -> Callable[[RecordPath], File]
    scheme_paths = {}
    for key in SCHEME_KEYS:
        encoded_key = ensure_text(key)
        scheme_paths[encoded_key] = ensure_text(
            getattr(scheme, key), encoding=sys.getfilesystemencoding()
        )

    def make_data_scheme_file(record_path):
        # type: (RecordPath) -> File
        normed_path = os.path.normpath(record_path)
        try:
            _, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)
        except ValueError:
            message = (
                "Unexpected file in {}: {!r}. .data directory contents"
                " should be named like: '<scheme key>/<path>'."
            ).format(wheel_path, record_path)
            raise InstallationError(message)

        try:
            scheme_path = scheme_paths[scheme_key]
        except KeyError:
            valid_scheme_keys = ", ".join(sorted(scheme_paths))
            message = (
                "Unknown scheme key used in {}: {} (for file {!r}). .data"
                " directory contents should be in subdirectories named"
                " with a valid scheme key ({})"
            ).format(wheel_path, scheme_key, record_path, valid_scheme_keys)
            raise InstallationError(message)

        dest_path = os.path.join(scheme_path, dest_subpath)
        assert_no_path_traversal(scheme_path, dest_path)
        return ZipBackedFile(record_path, dest_path, zip_file)

    return make_data_scheme_file