Commit ff79486b authored by Nick Coghlan's avatar Nick Coghlan

Close #15519: Properly expose WindowsRegistryFinder in importlib and bring the...

Close #15519: Properly expose WindowsRegistryFinder in importlib and bring the name into line with normal import terminology. Original patch by Eric Snow
parent 8a9080fe
...@@ -603,6 +603,17 @@ find and load modules. ...@@ -603,6 +603,17 @@ find and load modules.
instantiation. instantiation.
.. class:: WindowsRegistryFinder
:term:`Finder` for modules declared in the Windows registry. This class
implements the :class:`importlib.abc.MetaPathFinder` ABC.
Only class methods are defined by this class to alleviate the need for
instantiation.
.. versionadded:: 3.3
.. class:: PathFinder .. class:: PathFinder
:term:`Finder` for :data:`sys.path`. This class implements the :term:`Finder` for :data:`sys.path`. This class implements the
......
...@@ -720,9 +720,9 @@ class FrozenImporter: ...@@ -720,9 +720,9 @@ class FrozenImporter:
return _imp.is_frozen_package(fullname) return _imp.is_frozen_package(fullname)
class WindowsRegistryImporter: class WindowsRegistryFinder:
"""Meta path import for modules declared in the Windows registry. """Meta path finder for modules declared in the Windows registry.
""" """
REGISTRY_KEY = ( REGISTRY_KEY = (
...@@ -1683,7 +1683,7 @@ def _setup(sys_module, _imp_module): ...@@ -1683,7 +1683,7 @@ def _setup(sys_module, _imp_module):
if builtin_os == 'nt': if builtin_os == 'nt':
SOURCE_SUFFIXES.append('.pyw') SOURCE_SUFFIXES.append('.pyw')
if '_d.pyd' in _imp.extension_suffixes(): if '_d.pyd' in _imp.extension_suffixes():
WindowsRegistryImporter.DEBUG_BUILD = True WindowsRegistryFinder.DEBUG_BUILD = True
def _install(sys_module, _imp_module): def _install(sys_module, _imp_module):
...@@ -1694,5 +1694,5 @@ def _install(sys_module, _imp_module): ...@@ -1694,5 +1694,5 @@ def _install(sys_module, _imp_module):
sys.meta_path.append(BuiltinImporter) sys.meta_path.append(BuiltinImporter)
sys.meta_path.append(FrozenImporter) sys.meta_path.append(FrozenImporter)
if _os.__name__ == 'nt': if _os.__name__ == 'nt':
sys.meta_path.append(WindowsRegistryImporter) sys.meta_path.append(WindowsRegistryFinder)
sys.meta_path.append(PathFinder) sys.meta_path.append(PathFinder)
...@@ -59,7 +59,7 @@ class MetaPathFinder(Finder): ...@@ -59,7 +59,7 @@ class MetaPathFinder(Finder):
raise NotImplementedError raise NotImplementedError
_register(MetaPathFinder, machinery.BuiltinImporter, machinery.FrozenImporter, _register(MetaPathFinder, machinery.BuiltinImporter, machinery.FrozenImporter,
machinery.PathFinder) machinery.PathFinder, machinery.WindowsRegistryFinder)
class PathEntryFinder(Finder): class PathEntryFinder(Finder):
......
...@@ -6,6 +6,7 @@ from ._bootstrap import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES, ...@@ -6,6 +6,7 @@ from ._bootstrap import (SOURCE_SUFFIXES, DEBUG_BYTECODE_SUFFIXES,
OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES) OPTIMIZED_BYTECODE_SUFFIXES, BYTECODE_SUFFIXES)
from ._bootstrap import BuiltinImporter from ._bootstrap import BuiltinImporter
from ._bootstrap import FrozenImporter from ._bootstrap import FrozenImporter
from ._bootstrap import WindowsRegistryFinder
from ._bootstrap import PathFinder from ._bootstrap import PathFinder
from ._bootstrap import FileFinder from ._bootstrap import FileFinder
from ._bootstrap import SourceFileLoader from ._bootstrap import SourceFileLoader
......
...@@ -34,7 +34,7 @@ class MetaPathFinder(InheritanceTests, unittest.TestCase): ...@@ -34,7 +34,7 @@ class MetaPathFinder(InheritanceTests, unittest.TestCase):
superclasses = [abc.Finder] superclasses = [abc.Finder]
subclasses = [machinery.BuiltinImporter, machinery.FrozenImporter, subclasses = [machinery.BuiltinImporter, machinery.FrozenImporter,
machinery.PathFinder] machinery.PathFinder, machinery.WindowsRegistryFinder]
class PathEntryFinder(InheritanceTests, unittest.TestCase): class PathEntryFinder(InheritanceTests, unittest.TestCase):
......
...@@ -72,6 +72,9 @@ Core and Builtins ...@@ -72,6 +72,9 @@ Core and Builtins
Library Library
------- -------
- Issue #15519: Properly expose WindowsRegistryFinder in importlib (and use
the correct term for it). Original patch by Eric Snow.
- Issue #15502: Bring the importlib ABCs into line with the current state - Issue #15502: Bring the importlib ABCs into line with the current state
of the import protocols given PEP 420. Original patch by Eric Snow. of the import protocols given PEP 420. Original patch by Eric Snow.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment