Issue2860

classification
Title: from some_java_lib import * does not import all names
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7.2
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gbach, jeff.allen
Priority: normal Keywords:

Created on 2020-02-07.13:37:04 by gbach, last changed 2020-02-11.22:34:00 by jeff.allen.

Messages
msg12978 (view) Author: Gunter (gbach) Date: 2020-02-07.13:37:04
For some imports like this

from javax.xml.parsers import *

not all names are imported.

With jython 2.7.1 it worked and 

DocumentBuilderFactory

was available.

With jython2.7.2 it is not in my context.

I will try to add code to reproduce since on the REPL this works fine in 2.7.2
msg12980 (view) Author: Jeff Allen (jeff.allen) Date: 2020-02-08.10:37:18
The fact it works in the REPL suggest we may still be dealing with a publication problem, at least if concurrency is involved.

Is this 2.7.2b3?

The other reason for missing classes might be a bug in the package cache. Giving one or more -v options to org.python.util.jython will tell you where it is looking for things, and if different in the REPL from the script, would provide perhaps the best clue.
msg12982 (view) Author: Gunter (gbach) Date: 2020-02-11.08:03:49
Unfortunately the issue is not limited to "*"-imports.
Now I got some errors (Web-portal using Tomcat) like this:

from datetime import datetime
print datetime.now()

-> Attribute-Error datetime has no attribute "now"

I am using jython 2.7.2b2
msg12984 (view) Author: Jeff Allen (jeff.allen) Date: 2020-02-11.22:34:00
I'm not able to reproduce this.

PS 272b2-trial> inst\bin\jython -V
Jython 2.7.2b2
PS 272b2-trial> inst\bin\jython -c "from javax.xml.parsers import *; print DocumentBuilderFactory"
<type 'javax.xml.parsers.DocumentBuilderFactory'>
PS 272b2-trial> inst\bin\jython -c "from datetime import datetime; print datetime.now()"
2020-02-11 22:07:35.740000
PS 272b2-trial> inst\bin\jython -c "from datetime import datetime; print len(dir(datetime))"
79

This last is the same as in the REPL. But it sounds like #2834, especially if we are in a servlet context (therefore possibly concurrent).

Could you try on 2.7.2b3 ?
History
Date User Action Args
2020-02-11 22:34:00jeff.allensetmessages: + msg12984
2020-02-11 08:03:49gbachsetmessages: + msg12982
2020-02-08 10:37:19jeff.allensetpriority: normal
type: behaviour
messages: + msg12980
nosy: + jeff.allen
2020-02-07 13:37:04gbachcreate