pypa/pip · error · ValueError

Badly formatted data: {data!r}

Error message

Badly formatted data: {data!r}

What it means

Raised inside pip's Subversion backend while parsing the legacy on-disk `.svn/entries` file to recover the repository URL and revision. When the file begins with `<?xml` (older SVN formats) but the `_svn_xml_url_re` regex fails to locate a `<url>` element, pip treats the entries data as corrupt/unparseable and raises this ValueError. It indicates the working copy's SVN metadata is in a format pip does not understand (e.g. produced by an incompatible/old SVN client or truncated).

Source

Thrown at src/pip/_internal/vcs/subversion.py:151

        from pip._internal.exceptions import InstallationError

        entries_path = os.path.join(location, cls.dirname, "entries")
        if os.path.exists(entries_path):
            with open(entries_path) as f:
                data = f.read()
        else:  # subversion >= 1.7 does not have the 'entries' file
            data = ""

        url = None
        if data.startswith(("8", "9", "10")):
            entries = list(map(str.splitlines, data.split("\n\x0c\n")))
            del entries[0][0]  # get rid of the '8'
            url = entries[0][3]
            revs = [int(d[9]) for d in entries if len(d) > 9 and d[9]] + [0]
        elif data.startswith("<?xml"):
            match = _svn_xml_url_re.search(data)
            if not match:
                raise ValueError(f"Badly formatted data: {data!r}")
            url = match.group(1)  # get repository URL
            revs = [int(m.group(1)) for m in _svn_rev_re.finditer(data)] + [0]
        else:
            try:
                # subversion >= 1.7
                # Note that using get_remote_call_options is not necessary here
                # because `svn info` is being run against a local directory.
                # We don't need to worry about making sure interactive mode
                # is being used to prompt for passwords, because passwords
                # are only potentially needed for remote server requests.
                xml = cls.run_command(
                    ["info", "--xml", location],
                    show_stdout=False,
                    stdout_only=True,
                )
                match = _svn_info_xml_url_re.search(xml)
                assert match is not None
                url = match.group(1)

View on GitHub (pinned to d7d0d0a394)

Solutions

  1. Re-checkout the SVN working copy with a current `svn` client so `.svn/entries` is regenerated, then re-run pip.
  2. Upgrade your Subversion client to a version whose WC metadata pip can parse (SVN >= 1.7 uses the `svn info --xml` fallback path that does not hit this error).
  3. If you only need pip to read the URL, run `svn info <path>` to confirm the repo is readable; if that fails, repair/checkout fresh.
  4. Avoid pointing pip directly at a foreign SVN working copy; pass an `svn+http(s)://` URL instead of a local WC path.

Example fix

# before
pip install -e ./my_svn_checkout   # stale .svn/entries triggers the error

# after
rm -rf my_svn_checkout && svn checkout https://myrepo/svn/MyApp/trunk my_svn_checkout
pip install -e my_svn_checkout
Defensive patterns

Strategy: validation

Validate before calling

# Before pointing pip at an SVN working copy, sanity-check the entries file:
import os, re
entries = os.path.join(wc_path, ".svn", "entries")
if os.path.exists(entries):
    data = open(entries).read()
    if data.startswith("<?xml") and not re.search(r"<url>([^<]+)</url>", data):
        raise RuntimeError("SVN entries file is unparseable; re-checkout required")

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Calling `pip` operations that inspect an SVN checkout (install/freeze/-e) where `cls.dirname/entries` exists, starts with `<?xml`, and the URL regex returns no match. Specifically in `Subversion._get_svn_url_rev` at the `_svn_xml_url_re.search(data)` branch returning None.

Common situations: A working copy created by a very old SVN client (pre-1.4 WC format), a manually edited or partially-written `.svn/entries` file, a checkout corrupted by a crash/kill during `svn checkout`, or filesystem corruption. Also seen after SVN upgraded the WC format in place and left stale metadata.

Related errors


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/582f2b8d02656538.json. Report an issue: GitHub.