Issue1742

classification
Title: Finders in sys.meta_path do not work for Java modules in packages
Type: Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, geoffbache, jeff.allen, nonameentername, zyasoft
Priority: low Keywords:

Created on 2011-04-26.14:11:01 by geoffbache, last changed 2018-03-17.17:30:22 by jeff.allen.

Messages
msg6515 (view) Author: Geoff Bache (geoffbache) Date: 2011-04-26.14:11:01
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.
msg11825 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-17.17:30:22
Not sure why this has languished so long, as I think the answer is simple.

Finders are used to locate Python modules/packages for import, which xml and its modules are, and javax and its packages are not. Once we know that javax is a java package, it is only necessary to search the class path.
History
Date User Action Args
2018-03-17 17:30:22jeff.allensetstatus: open -> closed
resolution: remind -> invalid
messages: + msg11825
nosy: + jeff.allen
2014-09-17 02:20:34zyasoftsetnosy: + nonameentername
2014-09-17 02:20:00zyasoftsetnosy: + zyasoft
2013-02-19 23:56:59fwierzbickisetfiles: - generictramadolhclonline.html
2013-02-19 23:56:36fwierzbickisetfiles: - cheapcodfedextramadolvery.html
2013-02-19 23:56:25fwierzbickisetpriority: low
nosy: + fwierzbicki
resolution: remind
versions: + Jython 2.5, - 2.5.2rc
2011-07-27 12:48:05junior1971setfiles: + generictramadolhclonline.html
2011-07-27 12:03:41junior1971setfiles: + cheapcodfedextramadolvery.html
2011-04-26 14:11:01geoffbachecreate