Skip to content

Commit 0e20dba

Browse files
Merge pull request #762 from pypa/bugfix/760-unicodedecode-error
Support UTF-8 in setup.cfg files
2 parents e128317 + d90f165 commit 0e20dba

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/setuptools_scm/_integration/setuptools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def read_dist_name_from_setup_cfg(
1414
parser = configparser.ConfigParser()
1515

1616
if isinstance(input, (os.PathLike, str)):
17-
parser.read([input])
17+
parser.read([input], encoding="utf-8")
1818
else:
1919
parser.read_file(input)
2020

testing/test_integration.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pytest
88

9+
import setuptools_scm._integration.setuptools
910
from .wd_wrapper import WorkDir
1011
from setuptools_scm import PRETEND_KEY
1112
from setuptools_scm import PRETEND_KEY_NAMED
@@ -152,3 +153,20 @@ def test_distribution_procides_extras() -> None:
152153

153154
dist = distribution("setuptools_scm")
154155
assert sorted(dist.metadata.get_all("Provides-Extra")) == ["test", "toml"]
156+
157+
158+
@pytest.mark.issue(760)
159+
def test_unicode_in_setup_cfg(tmp_path: Path) -> None:
160+
cfg = tmp_path / "setup.cfg"
161+
cfg.write_text(
162+
textwrap.dedent(
163+
"""
164+
[metadata]
165+
name = configparser
166+
author = Łukasz Langa
167+
"""
168+
),
169+
encoding="utf-8",
170+
)
171+
name = setuptools_scm._integration.setuptools.read_dist_name_from_setup_cfg(cfg)
172+
assert name == "configparser"

0 commit comments

Comments
 (0)