[Python-Dev] how important is setting co_filename for a module being imported to what file is set to? (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Aug 31 15:19:29 CEST 2009


Antoine Pitrou wrote:

Brett Cannon <brett python.org> writes:

Now I can't change cofilename from Python as it's a read-only attribute and thus can't match this functionality in importlib w/o creating some custom code to allow me to specify the cofilename somewhere Why can't we simply make cofilename a writable attribute instead of inventing some complicated API?

I thought of that question as well, but the later exchange between Guido and Brett made me realise that a lot more than the top level module code object is affected here - the adjustment also needs to be propagated to the code objects created by the module for functions and generators and so forth.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list