Skip to content

Commit 50a1549

Browse files
committed
Ignore comments in entry point parsing. Fixes #297.
1 parent 1b9637a commit 50a1549

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v3.9.1
22
======
33

44
* #296: Exclude 'prepare' package.
5+
* #297: Fix ValueError when entry points contains comments.
56

67
v3.9.0
78
======

importlib_metadata/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class Sectioned:
8282
_sample = textwrap.dedent(
8383
"""
8484
[sec1]
85+
# comments ignored
8586
a = 1
8687
b = 2
8788
@@ -102,13 +103,17 @@ def __call__(self, line):
102103

103104
@classmethod
104105
def get_sections(cls, text):
105-
lines = filter(None, map(str.strip, text.splitlines()))
106+
lines = filter(cls.valid, map(str.strip, text.splitlines()))
106107
return (
107108
(section, map(cls.parse_value, values))
108109
for section, values in itertools.groupby(lines, cls())
109110
if section is not None
110111
)
111112

113+
@staticmethod
114+
def valid(line):
115+
return line and not line.startswith('#')
116+
112117
@staticmethod
113118
def parse_value(line):
114119
return map(str.strip, line.split("=", 1))

0 commit comments

Comments
 (0)