This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dsweeton
Recipients
Date 2003-03-05.20:52:29
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Only the first instanceof a dynamically loaded module 
gets the __file__ attribute. It is missing from all later 
instances.

The problem is in importdl.c in the function 
_PyImport_LoadDynamicModule. The first time a 
module is loaded a copy of its module dictionary is 
made by a call to _PyImport_FixupExtension. After that 
copy was made, _PyImport_LoadDynamicModule adds 
the _file__ attribute to the original module dictionary. 
Thus the first instance of the module has the 
__file__attribute.

Later when another instance of the module loads, its 
module dictionary is duplicated from the copy of the 
dictionary from the first instance. The problem is that 
when that copy was made, the __file__ attribute was not 
yet there. Thus the later instance of the module does 
not have the __file__ attribute.

The required fix is in importdl.c and consists of simply 
moving the call of _PyImport_FixupExtension to a point 
just after the __file__ attribute is added, instead of just 
before it. I have tested this fix and it solves the problem.
History
Date User Action Args
2007-08-23 14:11:41adminlinkissue698282 messages
2007-08-23 14:11:41admincreate