[Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?
robertc at robertcollins.net
Mon Aug 31 02:13:12 CEST 2009
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
- because the pyc is already on disk?
Thats been an invaluable 'wtf' debugging tool at various times, because
the odd provenance of the path in the pyc makes it extremely clear that
what is being loaded isn't what one had thought was being loaded.
OTOH, always showing the path that the pyc was *actually found at* would
fix the weirdness that occurs when you mv a python tree from one place
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: This is a digitally signed message part
More information about the Python-Dev