Issue2832
Created on 2019-11-19.12:52:13 by ruud, last changed 2019-11-24.23:39:10 by jeff.allen.
msg12778 (view) |
Author: Ruud van den Brink (ruud) |
Date: 2019-11-19.12:52:12 |
|
There seems to be something broken with file handling in modules; below I isolated the problem:
- create a subfolder 'test'
- in the folder test, touch an __init__.py
- in the folder test, create a file 'trial.py' with the following contents:
from __future__ import print_function
def hello():
print('Hello world!')
Now run Jython:
java -Dpython.console -jar Jython-standalone-2.7.2b2.jar
>>> import test
>>> test.trial.hello()
Traceback (most recent call last):
File "<stdin>", line 1 in <module>
AttributeError: module' object has no attribute 'trial'
With Jython 2.7.1 (or 2.7.2a1):
java -Dpython.console -jar Jython-standalone-2.7.1.jar
>>> import test
>>> test.trial.hello()
Hello World!
>>>
Using Jython standalone on [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_231 / Windows 7
|
msg12786 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2019-11-23.10:12:10 |
|
The behaviour in 2.7.1 is incorrect (see #2654). You must import test.trial explicitly. Compare CPython.
The incorrect behaviour is a malign consequence of attempting to do what seems natural for Java objects (see #2455). We have adjusted this behaviour several times over the evolution of Jython.
I wrote something to explain the problem and trace the logic (https://inside-jython.readthedocs.io/en/latest/import.html). It is long.
|
msg12788 (view) |
Author: Ruud van den Brink (ruud) |
Date: 2019-11-24.11:10:45 |
|
Clarifies it all, issue can be closed and I'll update my code.
|
|
Date |
User |
Action |
Args |
2019-11-24 23:39:10 | jeff.allen | set | status: pending -> closed |
2019-11-24 11:10:45 | ruud | set | messages:
+ msg12788 |
2019-11-23 10:12:10 | jeff.allen | set | status: open -> pending resolution: invalid messages:
+ msg12786 nosy:
+ jeff.allen |
2019-11-19 12:52:13 | ruud | create | |
|