Message158488
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. |
|
Date |
User |
Action |
Args |
2012-04-16 17:46:44 | brett.cannon | set | recipients:
+ brett.cannon, pitrou, r.david.murray, eric.snow |
2012-04-16 17:46:44 | brett.cannon | set | messageid: <1334598404.1.0.682189803944.issue14551@psf.upfronthosting.co.za> |
2012-04-16 17:46:43 | brett.cannon | link | issue14551 messages |
2012-04-16 17:46:43 | brett.cannon | create | |
|