summaryrefslogtreecommitdiffstats
path: root/Lib/importlib/metadata.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-03-13 21:30:07 (GMT)
committerGitHub <noreply@github.com>2022-03-13 21:30:07 (GMT)
commit177be52517da9a876a3f9e670f88c4731b906986 (patch)
tree63815aebf19a4b3c0818652edc0ad8ac36724588 /Lib/importlib/metadata.py
parentbda64b3c0c4e45de4c82ba1b8722f56db5ac88ba (diff)
downloadcpython-177be52517da9a876a3f9e670f88c4731b906986.zip
cpython-177be52517da9a876a3f9e670f88c4731b906986.tar.gz
cpython-177be52517da9a876a3f9e670f88c4731b906986.tar.bz2
[3.9] bpo-47004: Sync with importlib_metadata 4.11.3. (GH-31854). (GH-31859)
(cherry picked from commit b1e286860742e7ba6fadc75e3ddb6c2899a56919) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'Lib/importlib/metadata.py')
-rw-r--r--Lib/importlib/metadata.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/importlib/metadata.py b/Lib/importlib/metadata.py
index 7b8038f..647fd3e 100644
--- a/Lib/importlib/metadata.py
+++ b/Lib/importlib/metadata.py
@@ -45,6 +45,15 @@ class EntryPoint(
See `the packaging docs on entry points
<https://packaging.python.org/specifications/entry-points/>`_
for more information.
+
+ >>> ep = EntryPoint(
+ ... name=None, group=None, value='package.module:attr [extra1, extra2]')
+ >>> ep.module
+ 'package.module'
+ >>> ep.attr
+ 'attr'
+ >>> ep.extras
+ ['extra1', 'extra2']
"""
pattern = re.compile(
@@ -91,7 +100,7 @@ class EntryPoint(
@property
def extras(self):
match = self.pattern.match(self.value)
- return list(re.finditer(r'\w+', match.group('extras') or ''))
+ return re.findall(r'\w+', match.group('extras') or '')
@classmethod
def _from_config(cls, config):
@@ -308,7 +317,7 @@ class Distribution:
def _read_egg_info_reqs(self):
source = self.read_text('requires.txt')
- return source and self._deps_from_requires_text(source)
+ return None if source is None else self._deps_from_requires_text(source)
@classmethod
def _deps_from_requires_text(cls, source):