From 9ffe85e1e86bc6718f105f2ab9833ef80f691367 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Sun, 26 May 2013 16:45:10 -0400 Subject: 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. --- Lib/importlib/abc.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/importlib/abc.py') diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py index 7752ac4778..cdcf244d38 100644 --- a/Lib/importlib/abc.py +++ b/Lib/importlib/abc.py @@ -165,6 +165,13 @@ class InspectLoader(Loader): """ raise ImportError + def source_to_code(self, data, path=''): + """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) -- cgit v1.2.1