I'm not complaining, just saying I didn't notice. I essentially did the same with get_source/get_bytecode so as to be able to set __file__.

When I get around to it I will create a RunpyLoader in importlib.abc and add the method in the proper machinery loaders.

On Jul 4, 2009 3:43 PM, "Nick Coghlan" <ncoghlan@gmail.com> wrote:

Paul Moore wrote: > 2009/7/4 Brett Cannon <brett@python.org>:

>>> (runpy is also a lot happier with >>> them when they expose get_filename(), a relatively recent ...

I probably should have been noisier about that when I added it. I'm
pretty sure it did come up on this list, but it would have been
somewhere in the middle of a runpy discussion: runpy was stuck because
it only uses PEP 302 to *find* the modules it needs, but not to actually
load them. In the original version of PEP 302 the only way to get a
loader to tell you the filename was to load the module and see what it
set __file__ to, which wasn't useful in the runpy case.

If I recall correctly, at the time when PJE was rationalising the code
duplication between runpy and pkglib the comment was also made that
runpy's get_filename() optional loader extension should be mentioned in
PEP 302. runpy still works for loaders that don't provide it, it just
can't set __file__ or sys.argv[0] correctly in those cases.


Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia