[Python-Dev] how important is setting co_filename for a module being imported to what file is set to? (original) (raw)
Brett Cannon brett at python.org
Mon Aug 31 01:28:25 CEST 2009
- Previous message: [Python-Dev] Fast Implementation for ZIP decryption
- Next message: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I am going through and running the entire test suite using importlib to ferret out incompatibilities. I have found a bunch, although all rather minor (raising a different exception typically; not even sure they are worth backporting as anyone reliant on the old exceptions might get a nasty surprise in the next micro release), and now I am down to my last failing test suite: test_import.
Ignoring the execution bit problem (http://bugs.python.org/issue6526 but I have no clue why this is happening), I am bumping up against TestPycRewriting.test_incorrect_code_name. Turns out that import resets co_filename on a code object to file before exec'ing it to create a module's namespace in order to ignore the file name passed into compile() for the filename argument. Now I can't change co_filename 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 co_filename somewhere (marshal.loads() or some new function).
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?
-Brett
- Previous message: [Python-Dev] Fast Implementation for ZIP decryption
- Next message: [Python-Dev] how important is setting co_filename for a module being imported to what __file__ is set to?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]