bpo-40050: Fix importlib._bootstrap_external (GH-19135) · python/cpython@83d46e0 (original) (raw)

`@@ -716,9 +716,9 @@ class WindowsRegistryFinder:

`

716

716

`@classmethod

`

717

717

`def _open_registry(cls, key):

`

718

718

`try:

`

719

``

`-

return _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, key)

`

``

719

`+

return winreg.OpenKey(winreg.HKEY_CURRENT_USER, key)

`

720

720

`except OSError:

`

721

``

`-

return _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key)

`

``

721

`+

return winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key)

`

722

722

``

723

723

`@classmethod

`

724

724

`def _search_registry(cls, fullname):

`

`@@ -730,7 +730,7 @@ def _search_registry(cls, fullname):

`

730

730

`sys_version='%d.%d' % sys.version_info[:2])

`

731

731

`try:

`

732

732

`with cls._open_registry(key) as hkey:

`

733

``

`-

filepath = _winreg.QueryValue(hkey, '')

`

``

733

`+

filepath = winreg.QueryValue(hkey, '')

`

734

734

`except OSError:

`

735

735

`return None

`

736

736

`return filepath

`

`@@ -1584,14 +1584,7 @@ def _setup(_bootstrap_module):

`

1584

1584

`sys = _bootstrap.sys

`

1585

1585

`_imp = _bootstrap._imp

`

1586

1586

``

1587

``

`-

Directly load built-in modules needed during bootstrap.

`

1588

1587

`self_module = sys.modules[name]

`

1589

``

`-

for builtin_name in ('_io', '_warnings', 'builtins', 'marshal'):

`

1590

``

`-

if builtin_name not in sys.modules:

`

1591

``

`-

builtin_module = _bootstrap._builtin_from_name(builtin_name)

`

1592

``

`-

else:

`

1593

``

`-

builtin_module = sys.modules[builtin_name]

`

1594

``

`-

setattr(self_module, builtin_name, builtin_module)

`

1595

1588

``

1596

1589

`# Directly load the os module (needed during bootstrap).

`

1597

1590

`os_details = ('posix', ['/']), ('nt', ['\', '/'])

`

`@@ -1610,23 +1603,22 @@ def _setup(_bootstrap_module):

`

1610

1603

`continue

`

1611

1604

`else:

`

1612

1605

`raise ImportError('importlib requires posix or nt')

`

``

1606

+

1613

1607

`setattr(self_module, '_os', os_module)

`

1614

1608

`setattr(self_module, 'path_sep', path_sep)

`

1615

1609

`setattr(self_module, 'path_separators', ''.join(path_separators))

`

1616

1610

`setattr(self_module, '_pathseps_with_colon', {f':{s}' for s in path_separators})

`

1617

1611

``

1618

``

`-

Directly load the _thread module (needed during bootstrap).

`

1619

``

`-

thread_module = _bootstrap._builtin_from_name('_thread')

`

1620

``

`-

setattr(self_module, '_thread', thread_module)

`

1621

``

-

1622

``

`-

Directly load the _weakref module (needed during bootstrap).

`

1623

``

`-

weakref_module = _bootstrap._builtin_from_name('_weakref')

`

1624

``

`-

setattr(self_module, '_weakref', weakref_module)

`

1625

``

-

1626

``

`-

Directly load the winreg module (needed during bootstrap).

`

``

1612

`+

Directly load built-in modules needed during bootstrap.

`

``

1613

`+

builtin_names = ['_io', '_warnings', 'marshal']

`

1627

1614

`if builtin_os == 'nt':

`

1628

``

`-

winreg_module = _bootstrap._builtin_from_name('winreg')

`

1629

``

`-

setattr(self_module, '_winreg', winreg_module)

`

``

1615

`+

builtin_names.append('winreg')

`

``

1616

`+

for builtin_name in builtin_names:

`

``

1617

`+

if builtin_name not in sys.modules:

`

``

1618

`+

builtin_module = _bootstrap._builtin_from_name(builtin_name)

`

``

1619

`+

else:

`

``

1620

`+

builtin_module = sys.modules[builtin_name]

`

``

1621

`+

setattr(self_module, builtin_name, builtin_module)

`

1630

1622

``

1631

1623

`# Constants

`

1632

1624

`setattr(self_module, '_relax_case', _make_relax_case())

`