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

Fred Drake fdrake at acm.org
Mon Aug 31 23:04:25 CEST 2009


On Aug 31, 2009, at 4:47 PM, Antoine Pitrou wrote:
> I am really not opinionated on this one. I was just pointing out  
> that choosing a
> non-obvious solution generally requires good reasons to do so. The  
> marshal
> format compaction sounds like premature optimization, since nobody  
> seems to have
> formulated such a request.


Every time I've been bitten by the wrong co_filename values (usually  
from tracebacks), changing the way marshal creates code objects to use  
a values passed in has been the thing that made the most sense to me.

The feature request that's involved here, getting correct co_filename  
values, can be implemented in different ways, sure.  This particular  
change produces the least impact in the because it *doesn't* change  
the mutability of code objects.

I for one appreciate that, mostly because I'm simply wary of making  
code objects mutable in this way having unexpected side effects in  
some library.


   -Fred

-- 
Fred Drake   <fdrake at acm.org>



More information about the Python-Dev mailing list