Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fbc7851

Browse files
Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder.
1 parent 9dee304 commit fbc7851

4 files changed

Lines changed: 1892 additions & 1861 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ def find_spec(cls, fullname, path=None, target=None):
14061406
@classmethod
14071407
def find_module(cls, fullname, path=None):
14081408
"""Find module named in the registry."""
1409-
spec = self.find_spec(fullname, path)
1409+
spec = cls.find_spec(fullname, path)
14101410
if spec is not None:
14111411
return spec.loader
14121412
else:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from . import util
2+
frozen_machinery, source_machinery = util.import_importlib('importlib.machinery')
3+
4+
import sys
5+
import unittest
6+
7+
8+
@unittest.skipUnless(sys.platform.startswith('win'), 'requires Windows')
9+
class WindowsRegistryFinderTests:
10+
11+
# XXX Need a test that finds the spec via the registry.
12+
13+
def test_find_spec_missing(self):
14+
spec = self.machinery.WindowsRegistryFinder.find_spec('spam')
15+
self.assertIs(spec, None)
16+
17+
def test_find_module_missing(self):
18+
loader = self.machinery.WindowsRegistryFinder.find_module('spam')
19+
self.assertIs(loader, None)
20+
21+
22+
class Frozen_WindowsRegistryFinderTests(WindowsRegistryFinderTests,
23+
unittest.TestCase):
24+
machinery = frozen_machinery
25+
26+
27+
class Source_WindowsRegistryFinderTests(WindowsRegistryFinderTests,
28+
unittest.TestCase):
29+
machinery = source_machinery

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Core and Builtins
3636
- Issue #19736: Add module-level statvfs constants defined for GNU/glibc
3737
based systems.
3838

39+
- Issue #20097: Fix bad use of "self" in importlib's WindowsRegistryFinder.
40+
3941
- Issue #19729: In str.format(), fix recursive expansion in format spec.
4042

4143
- Issue #19638: Fix possible crash / undefined behaviour from huge (more than 2

0 commit comments

Comments
 (0)