[Python-checkins] [3.10] bpo-43643: Sync with python/importlib_resources at c17a610aad. (GH-26284) (GH-26286)
miss-islington
webhook-mailer at python.org
Fri May 21 13:52:34 EDT 2021
https://github.com/python/cpython/commit/fdb65e399ea4e2d13dd41d65662ba25cafe15f1d
commit: fdb65e399ea4e2d13dd41d65662ba25cafe15f1d
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-05-21T10:52:24-07:00
summary:
[3.10] bpo-43643: Sync with python/importlib_resources at c17a610aad. (GH-26284) (GH-26286)
* [bpo-43643](): Sync with python/importlib_resources at c17a610aad.
* Sync with python/importlib_resources at 89fd5e961a.
(cherry picked from commit 875b3d84b3072b2d3c352ad9f0ff52c441fbd12e)
Co-authored-by: Jason R. Coombs <jaraco at jaraco.com>
Automerge-Triggered-By: GH:jaraco
files:
A Misc/NEWS.d/next/Library/2021-05-21-12-12-35.bpo-43643.GWnmcF.rst
M Lib/importlib/_common.py
M Lib/importlib/readers.py
M Lib/test/test_importlib/test_reader.py
diff --git a/Lib/importlib/_common.py b/Lib/importlib/_common.py
index 03383048ad7365..ed509971ce718f 100644
--- a/Lib/importlib/_common.py
+++ b/Lib/importlib/_common.py
@@ -7,7 +7,7 @@
import importlib
from typing import Union, Any, Optional
-from .abc import ResourceReader
+from .abc import ResourceReader, Traversable
from ._adapters import wrap_spec
@@ -15,6 +15,7 @@
def files(package):
+ # type: (Package) -> Traversable
"""
Get a Traversable resource from a package
"""
diff --git a/Lib/importlib/readers.py b/Lib/importlib/readers.py
index 535c8283e9081d..3e91c1cae6758b 100644
--- a/Lib/importlib/readers.py
+++ b/Lib/importlib/readers.py
@@ -96,6 +96,7 @@ def joinpath(self, child):
def open(self, *args, **kwargs):
raise FileNotFoundError('{} is not a file'.format(self))
+ @property
def name(self):
return self._paths[0].name
diff --git a/Lib/test/test_importlib/test_reader.py b/Lib/test/test_importlib/test_reader.py
index b0bf49b8ba7f28..ed1f6be717b7e3 100644
--- a/Lib/test/test_importlib/test_reader.py
+++ b/Lib/test/test_importlib/test_reader.py
@@ -82,6 +82,12 @@ def test_repr(self):
"MultiplexedPath('{}')".format(self.folder),
)
+ def test_name(self):
+ self.assertEqual(
+ MultiplexedPath(self.folder).name,
+ os.path.basename(self.folder),
+ )
+
class NamespaceReaderTest(unittest.TestCase):
site_dir = str(pathlib.Path(__file__).parent)
diff --git a/Misc/NEWS.d/next/Library/2021-05-21-12-12-35.bpo-43643.GWnmcF.rst b/Misc/NEWS.d/next/Library/2021-05-21-12-12-35.bpo-43643.GWnmcF.rst
new file mode 100644
index 00000000000000..57157dfe217ee5
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-05-21-12-12-35.bpo-43643.GWnmcF.rst
@@ -0,0 +1 @@
+Declare readers.MultiplexedPath.name as a property per the spec.
More information about the Python-checkins
mailing list