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

Skip to content

Commit 0515619

Browse files
committed
Tweak the source/bytecode loader from importlib to use more of the PEP 302
protocol API.
1 parent 4afab6b commit 0515619

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lib/importlib/NOTES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ to do
77

88
+ PyLoader (for ABC)
99

10+
- load_module for source only
1011
- get_code for source only
1112

1213
+ PyFileLoader(PyLoader)
@@ -17,6 +18,7 @@ to do
1718

1819
+PyPycLoader (PyLoader, for ABC)
1920

21+
- load_module for source and bytecode
2022
- get_code for source and bytecode
2123

2224
+ PyPycFileLoader(PyPycLoader, PyFileLoader)

Lib/importlib/_bootstrap.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ def bytecode_path(self, fullname):
361361
# Not a property for easy overriding.
362362
return self._find_path(imp.PY_COMPILED)
363363

364-
@check_name
365364
@module_for_loader
366365
def load_module(self, module):
367366
"""Load a Python source or bytecode module."""
@@ -371,7 +370,7 @@ def load_module(self, module):
371370
code_object = self.get_code(module.__name__)
372371
module.__file__ = source_path if source_path else bytecode_path
373372
module.__loader__ = self
374-
if self._is_pkg:
373+
if self.is_package(name):
375374
module.__path__ = [module.__file__.rsplit(path_sep, 1)[0]]
376375
module.__package__ = module.__name__
377376
if not hasattr(module, '__path__'):
@@ -429,7 +428,6 @@ def write_bytecode(self, name, data):
429428
else:
430429
raise
431430

432-
@check_name
433431
def get_code(self, name):
434432
"""Return the code object for the module."""
435433
# XXX Care enough to make sure this call does not happen if the magic

0 commit comments

Comments
 (0)