mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Move importlib.abc.SourceLoader.source_to_code() to InspectLoader.
While the previous location was fine, it makes more sense to have the method higher up in the inheritance chain, especially at a point where get_source() is defined which is the earliest source_to_code() could programmatically be used in the inheritance tree in importlib.abc.
This commit is contained in:
parent
1256f1f438
commit
9ffe85e1e8
4 changed files with 66 additions and 15 deletions
|
|
@ -165,6 +165,13 @@ class InspectLoader(Loader):
|
|||
"""
|
||||
raise ImportError
|
||||
|
||||
def source_to_code(self, data, path='<string>'):
|
||||
"""Compile 'data' into a code object.
|
||||
|
||||
The 'data' argument can be anything that compile() can handle. The'path'
|
||||
argument should be where the data was retrieved (when applicable)."""
|
||||
return compile(data, path, 'exec', dont_inherit=True)
|
||||
|
||||
_register(InspectLoader, machinery.BuiltinImporter, machinery.FrozenImporter,
|
||||
machinery.ExtensionFileLoader)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue