Skip to content

Commit 5375cf6

Browse files
tomasr8rashansmith
andcommitted
Add DeprecationWarning for WindowsRegistryFinder
Co-authored-by: rashansmith <[email protected]>
1 parent b73ad85 commit 5375cf6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Lib/importlib/_bootstrap_external.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,14 @@ class WindowsRegistryFinder:
692692
'\\Modules\\{fullname}\\Debug')
693693
DEBUG_BUILD = (_MS_WINDOWS and '_d.pyd' in EXTENSION_SUFFIXES)
694694

695+
def __init__(self):
696+
import warnings
697+
warnings.warn("importlib.machinery.WindowsRegistryFinder is "
698+
"deprecated. Use site configuration instead. "
699+
"Future versions of Python may not enable this "
700+
"finder by default.",
701+
DeprecationWarning, stacklevel=2)
702+
695703
@staticmethod
696704
def _open_registry(key):
697705
try:

Lib/importlib/machinery.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def all_suffixes():
3333

3434
def __getattr__(name):
3535
import warnings
36+
3637
if name == 'DEBUG_BYTECODE_SUFFIXES':
3738
warnings.warn("importlib.machinery.DEBUG_BYTECODE_SUFFIXES is "
3839
"deprecated. Use importlib.machinery.BYTECODE_SUFFIXES "

Lib/test/test_importlib/test_api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,14 @@ def test_util(self):
493493

494494

495495
class TestDeprecations(unittest.TestCase):
496-
def test_machinery_deprecated_constants(self):
496+
def test_machinery_deprecated_members(self):
497497
from importlib import machinery
498-
for attr in ('DEBUG_BYTECODE_SUFFIXES', 'OPTIMIZED_BYTECODE_SUFFIXES'):
498+
attributes = (
499+
'DEBUG_BYTECODE_SUFFIXES',
500+
'OPTIMIZED_BYTECODE_SUFFIXES',
501+
'WindowsRegistryFinder',
502+
)
503+
for attr in attributes:
499504
with self.subTest(attr=attr):
500505
with self.assertWarns(DeprecationWarning):
501506
getattr(machinery, attr)

0 commit comments

Comments
 (0)