Brett Cannon <br...@python.org> added the comment:

To help refine this, so you would expect all of the usual import stuff (e.g. 
sys.modules use, generating bytecode, etc.), you just want a short-circuit to 
the loading when you happen to already know the name and desired file path?

Basically I want to kill off the file argument to imp.load_source() since it 
buys you nothing as import is no longer structured to work off of already 
opened files, and especially files opened to return text instead of bytes (the 
only reason load_*() even takes an open file is because it directly exposes 
stuff part way through import.c's import process).

And as for having an already opened file, don't count on load_module() sticking 
around since find_module() is going to go since, once again, it is only 
structured the way it is with its poor API because of how import.c's C code was 
structured.

Thinking about it a little, would importlib.util.SourceFileLoader(name, 
path).load_source() be an okay API for you? Or do you really want a function 
instead of a convenience method on a loader instance? I basically want to gut 
imp down to only stuff that is required for backwards-compatibility for for 
really low-level stuff that normal people never touch and have common stuff 
like load_source() be in importlib somewhere.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14551>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to