Message6515

Author geoffbache
Recipients geoffbache
Date 2011-04-26.14:11:01
SpamBayes Score 1.4433847e-09
Marked as misclassified No
Message-id <1303827061.82.0.815364231753.issue1742@psf.upfronthosting.co.za>
In-reply-to
Content
sys.meta_path is documented as for CPython, but it only seems to work for imports of Python modules. For example, if you run this code:

import sys

class MyFinder:
   def find_module(self, name, *args):
       print "Checking", name

sys.meta_path = [ MyFinder() ]

print "Importing xml.sax.handler..."
import xml.sax.handler
print "Importing javax.swing..."
import javax.swing

and note that when importing the Python module xml.sax.handler,
"find_module" gets called for every submodule as expected. When
importing javax.swing, it is called only once, on "javax", despite
"javax.swing" also being added to sys.modules. This seems to be the
case for any java package, i.e. only the top level interacts with
sys.meta_path, which as it's usually something like "org" or "com"
makes it not very useful.

This should either work (preferably) or be documented as not working.
History
Date User Action Args
2011-04-26 14:11:01geoffbachesetrecipients: + geoffbache
2011-04-26 14:11:01geoffbachesetmessageid: <1303827061.82.0.815364231753.issue1742@psf.upfronthosting.co.za>
2011-04-26 14:11:01geoffbachelinkissue1742 messages
2011-04-26 14:11:01geoffbachecreate