[Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?

Brett Cannon brett at python.org
Mon Aug 31 02:23:32 CEST 2009

On Sun, Aug 30, 2009 at 17:13, Robert Collins<robertc at robertcollins.net> wrote:
> On Sun, 2009-08-30 at 16:28 -0700, Brett Cannon wrote:
>> My question is how important is this functionality? Do I really need
>> to go through and add an argument to marshal.loads or some new
>> function just to set co_filename to something that someone explicitly
>> set in a .pyc file? Or I can let this go and have this be the one
>> place where builtins.__import__ and importlib.__import__ differ and
>> just not worry about it?
> Just to be clear, this would show up if I:
> had a python tree
> built and run stuff from it
> symlinked to that tree from somewhere else
> ran stuff from that somewhere else

Right; the code object would think it was loaded from the original
location it was created at instead of where it actually is. Now why
someone would want to move their .pyc files around instead of
recompiling I don't know short of not wanting to send someone source.


More information about the Python-Dev mailing list