Re: PEP 451: Big update.
Paul Moore <[email protected]> Thu, 19 Sep 2013 12:28:24 +0100
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CACac1F9BYKYCdbeOC61iq1dJvMCFHYMbywecKw+XvoG6-XKL1Q@mail.gmail.com> |
On 19 September 2013 11:22, Antoine Pitrou <[email protected]> wrote: >> origin - a string for the location from which the module is loaded, >> e.g. "builtin" for built-in modules and the filename for modules >> loaded from source. > > Filename or filepath? What if the module is stored in e.g. a ZIP file? I haven't been following this thread closely, but this is a good point. There is a general issue that for modules loaded off sys.path, the module "location" needs to be somehow jammed into a string form (the absolute path for files, zip/file/path.zip/location/in/zipfile for zipfiles, but potentially anything at all for custom loaders) and for things loaded off sys.meta_path there's no need for any concept of path at all (that's how builtins, frozen modules et al work). It's worth being clear on both how this origin should be constructed in the general case (for the guidance of people implementing non-standard importers) and what users of the data can assume when using the data (can they split the value on os.sep or '/', for example, or is it in effect an opaque token). Some of the blame for all this being vague at the moment is down to me - when we were writing PEP 302, I wasn't brave enough to claim that path entries could be opaque token values, but I didn't want to insist that all importers had to follow a specific structure. So I ignored the issue and we just ended up with normal paths, and zipfiles which treat the zipfile as a pseudo-directory. And no examples of corner cases to keep people honest. My apologies for that... Paul