Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

importlib.metadata.metadata("package") fails with email.errors.HeaderParseError when README contains valid markdown link #119650

Open
Assignees
jaraco
Labels
@hcording

Description

@hcording

Bug report

Bug description:

Here is a minimal example project (tested on Python 3.10):

pyproject.toml

[build-system]requires = ["hatchling"]build-backend = "hatchling.build"[project]name = "test"readme = "README.md"version = "0.1.0"

README.md

#Test[MIT](<https://choosealicense.com/licenses/mit/>)

test package:

  • __init__.py (empty)
  • bug.py:import importlib.metadata; print(importlib.metadata.metadata("test"))

To reproduce:
pip install -e .
python test/bug.py

Traceback:

Traceback (most recent call last):  File "bug.py", line 1, in <module>    import importlib.metadata; print(importlib.metadata.metadata("test"))  File "lib/python3.10/email/message.py", line 135, in __str__    return self.as_string()  File "lib/python3.10/email/message.py", line 158, in as_string    g.flatten(self, unixfrom=unixfrom)  File "/home/mint/miniforge3/lib/python3.10/email/generator.py", line 116, in flatten    self._write(msg)  File "lib/python3.10/email/generator.py", line 199, in _write    self._write_headers(msg)  File "lib/python3.10/email/generator.py", line 226, in _write_headers    self.write(self.policy.fold(h, v))  File "lib/python3.10/email/_policybase.py", line 326, in fold    return self._fold(name, value, sanitize=True)  File "lib/python3.10/email/_policybase.py", line 369, in _fold    parts.append(h.encode(linesep=self.linesep, maxlinelen=maxlinelen))  File "lib/python3.10/email/header.py", line 389, in encode    raise HeaderParseError("header value appears to contain "email.errors.HeaderParseError: header value appears to contain an embedded header: '# Test\n[MIT](<https://choosealicense.com/licenses/mit/>)'

It appears that[MIT] is seen as a header, as it would be in a TOML file. That's my best guess really. Any help is appreciated!

CPython versions tested on:

3.10

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp