Skip to content

Commit ff79486

Browse files
committed
Close python#15519: Properly expose WindowsRegistryFinder in importlib and bring the name into line with normal import terminology. Original patch by Eric Snow
1 parent 8a9080f commit ff79486

File tree

7 files changed

+2510
-2497
lines changed

7 files changed

+2510
-2497
lines changed

Doc/library/importlib.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,17 @@ find and load modules.
603603
instantiation.
604604

605605

606+
.. class:: WindowsRegistryFinder
607+
608+
:term:`Finder` for modules declared in the Windows registry. This class
609+
implements the :class:`importlib.abc.MetaPathFinder` ABC.
610+
611+
Only class methods are defined by this class to alleviate the need for
612+
instantiation.
613+
614+
.. versionadded:: 3.3
615+
616+
606617
.. class:: PathFinder
607618

608619
:term:`Finder` for :data:`sys.path`. This class implements the

Lib/importlib/_bootstrap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ def is_package(cls, fullname):
720720
return _imp.is_frozen_package(fullname)
721721

722722

723-
class WindowsRegistryImporter:
723+
class WindowsRegistryFinder:
724724

725-
"""Meta path import for modules declared in the Windows registry.
725+
"""Meta path finder for modules declared in the Windows registry.
726726
"""
727727

728728
REGISTRY_KEY = (
@@ -1683,7 +1683,7 @@ def _setup(sys_module, _imp_module):
16831683
if builtin_os == 'nt':
16841684
SOURCE_SUFFIXES.append('.pyw')
16851685
if '_d.pyd' in _imp.extension_suffixes():
1686-
WindowsRegistryImporter.DEBUG_BUILD = True
1686+
WindowsRegistryFinder.DEBUG_BUILD = True
16871687

16881688

16891689
def _install(sys_module, _imp_module):
@@ -1694,5 +1694,5 @@ def _install(sys_module, _imp_module):
16941694
sys.meta_path.append(BuiltinImporter)
16951695
sys.meta_path.append(FrozenImporter)
16961696
if _os.__name__ == 'nt':
1697-
sys.meta_path.append(WindowsRegistryImporter)
1697+
sys.meta_path.append(WindowsRegistryFinder)
16981698
sys.meta_path.append(PathFinder)

Lib/importlib/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def find_module(self, fullname, path):
5959
raise NotImplementedError
6060

6161
_register(MetaPathFinder, machinery.BuiltinImporter, machinery.FrozenImporter,
62-
machinery.PathFinder)
62+
machinery.PathFinder, machinery.WindowsRegistryFinder)
6363

6464

6565
class PathEntryFinder(Finder):

Lib/importlib/machinery.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES)
77
from ._bootstrap import BuiltinImporter
88
from ._bootstrap import FrozenImporter
9+
from ._bootstrap import WindowsRegistryFinder
910
from ._bootstrap import PathFinder
1011
from ._bootstrap import FileFinder
1112
from ._bootstrap import SourceFileLoader

Lib/test/test_importlib/test_abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MetaPathFinder(InheritanceTests, unittest.TestCase):
3434

3535
superclasses = [abc.Finder]
3636
subclasses = [machinery.BuiltinImporter, machinery.FrozenImporter,
37-
machinery.PathFinder]
37+
machinery.PathFinder, machinery.WindowsRegistryFinder]
3838

3939
class PathEntryFinder(InheritanceTests, unittest.TestCase):
4040

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Core and Builtins
7272
Library
7373
-------
7474

75+
- Issue #15519: Properly expose WindowsRegistryFinder in importlib (and use
76+
the correct term for it). Original patch by Eric Snow.
77+
7578
- Issue #15502: Bring the importlib ABCs into line with the current state
7679
of the import protocols given PEP 420. Original patch by Eric Snow.
7780

Python/importlib.h

Lines changed: 2489 additions & 2491 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)