pypa/pip · error · ValueError
Badly formatted data
Error message
Badly formatted data: {data!r} What it means
Raised by Subversion._get_svn_url_rev() when parsing the legacy SVN 'entries' file in XML format and the repository URL regex (_svn_xml_url_re) finds no match. This indicates the SVN metadata file exists and starts with '<?xml' but does not contain a recognizable url attribute.
Solutions
- Upgrade the SVN client: 'svn --version' — modern SVN uses a format that bypasses this code path
- Re-checkout the working copy with a current SVN client: 'svn checkout <url>'
- Run 'svn info <location>' manually to verify the working copy is valid
- Avoid SVN-based pip installs if possible; migrate to git or use a direct download
Example fix
// before pip install svn+http://example.com/svn/MyApp#egg=MyApp # old SVN working copy with malformed entries // after svn --version # upgrade if < 1.7 svn checkout http://example.com/svn/MyApp fresh_checkout pip install ./fresh_checkout
Defensive patterns
Strategy: try-catch
Type guard
import re
_XML_URL_RE = re.compile('url="([^"]+)"')
def svn_xml_has_url(data: str) -> bool:
return bool(_XML_URL_RE.search(data)) if data.startswith('<?xml') else True Try / catch
try:
url, rev = Subversion._get_svn_url_rev(location)
except ValueError as e:
if 'Badly formatted data' in str(e):
# re-checkout with a modern SVN client
raise EnvironmentError(f'SVN metadata corrupt or unsupported version: {e}')
raise Prevention
- Use a modern SVN client (>= 1.7) that bypasses the legacy entries file
- Re-checkout working copies with a current SVN version
- Verify with 'svn info <location>' before pip install
- Migrate from SVN to git where possible
When it happens
Trigger: Calling _get_svn_url_rev(location) where the .svn/entries file starts with '<?xml' but _svn_xml_url_re.search(data) returns None (no url="..." attribute found). Reached during SVN-based VCS installation or when pip inspects an SVN working copy.
Common situations: A very old or unusual SVN client version that wrote the entries file in a different XML schema. A corrupted .svn/entries file. An SVN working copy checked out by a third-party tool. This is increasingly rare as modern SVN (>= 1.7) uses a different metadata format that falls through to 'svn info'.
Related errors
- Error parsing entry points for
- Error parsing entry points for
- Ill-formed name/version string
- Invalid requirement
- Invalid section heading
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/582f2b8d02656538.
Report an issue: GitHub.
Appendix: 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 f399c37189)