Issue1879

classification
Title: -m command line option broken for scripts inside a jar file
Type: Severity: normal
Components: Core Versions: Jython 2.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: conflatedauto, darjus, fwierzbicki
Priority: Keywords:

Created on 2012-04-30.08:37:52 by conflatedauto, last changed 2013-02-19.21:50:47 by fwierzbicki.

Messages
msg7074 (view) Author: Adam (conflatedauto) Date: 2012-04-30.08:37:52
jython -m broken for scripts inside jar files

The workaround jython -c "import module; module.blah()" will work, but not if you don't have a blah function.

This is jy.bat


Version 2.5.2

C:\Working\working>java -classpath C:\Working\tools\maven\repository2\org\robotf
ramework\robotframework\2.7.1\robotframework-2.7.1.jar;C:\Working\tools\maven\re
pository2\tools\tools-core\1.3.1-SNAPSHOT\tools-core-1.3.1-SNAPSHOT.jar org.python
.util.jython
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_26
Type "help", "copyright", "credits" or "license" for more information.

C:\Working\working>jy -m editor.vimgen

C:\Working\working>java -classpath C:\Working\tools\maven\repository2\org\robotf
ramework\robotframework\2.7.1\robotframework-2.7.1.jar;C:\Working\tools\maven\re
pository2\tools\tools-core\1.3.1-SNAPSHOT\tools-core-1.3.1-SNAPSHOT.jar org.python
.util.jython -m editor.vimgen
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Working\tools\maven\repository2\org\robotframework\robotframework\2.7
.1\robotframework-2.7.1.jar\Lib\runpy.py", line 88, in run_module
AttributeError: 'ClasspathPyImporter' object has no attribute 'get_code'
C:\Working\working>jy -m editor/vimgen

C:\Working\working>java -classpath C:\Working\tools\maven\repository2\org\robotf
ramework\robotframework\2.7.1\robotframework-2.7.1.jar;C:\Working\tools\maven\re
pository2\tools\tools-core\1.3.1-SNAPSHOT\tools-core-1.3.1-SNAPSHOT.jar org.python
.util.jython -m editor/vimgen
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Working\tools\maven\repository2\org\robotframework\robotframework\2.7
.1\robotframework-2.7.1.jar\Lib\runpy.py", line 88, in run_module
AttributeError: 'ClasspathPyImporter' object has no attribute 'get_code'
C:\Working\working>jy -m editor/blah

Looking at the source it seems that ClasspathPyImporter is indeed lacking this method.


No such module is a different, correct error:

C:\Working\working>java -classpath C:\Working\tools\maven\repository2\org\robotf
ramework\robotframework\2.7.1\robotframework-2.7.1.jar;C:\Working\tools\maven\re
pository2\tools\tools-core\1.3.1-SNAPSHOT\tools-core-1.3.1-SNAPSHOT.jar org.python
.util.jython -m editor/blah
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Working\tools\maven\repository2\org\robotframework\robotframework\2.7
.1\robotframework-2.7.1.jar\Lib\runpy.py", line 87, in run_module
ImportError: No module named editor/blah



Still present under the latest beta release

C:\Working\working>jy -m editor/vimgen

C:\Working\working>rem set JYTHON=C:\Working\tools\maven\repository2\org\robotfr
amework\robotframework\2.7.1\robotframework-2.7.1.jar

C:\Working\working>set JYTHON=C:\Working\tools\jython\jython2.5.3b1\jython.jar

C:\Working\working>java -classpath C:\Working\tools\jython\jython2.5.3b1\jython.
jar;C:\Working\tools\maven\repository2\tools\tools-core\1.3.1-SNAPSHOT\tools-core-
1.3.1-SNAPSHOT.jar org.python.util.jython -m editor/vimgen
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Working\tools\jython\jython2.5.3b1\Lib\runpy.py", line 88, in run_mod
ule
    code = loader.get_code(mod_name)
AttributeError: 'ClasspathPyImporter' object has no attribute 'get_code'



Works for local scripts

C:\Working\working>dir *.py
 Volume in drive C has no label.
 Volume Serial Number is 7402-3955

 Directory of C:\Working\working

04/30/2012  11:11 AM                15 test.py
               1 File(s)             15 bytes
               0 Dir(s)  208,984,723,456 bytes free

C:\Working\working>jy -m test

C:\Working\working>rem set JYTHON=C:\Working\tools\maven\repository2\org\robotfr
amework\robotframework\2.7.1\robotframework-2.7.1.jar

C:\Working\working>set JYTHON=C:\Working\tools\jython\jython2.5.3b1\jython.jar

C:\Working\working>java -classpath C:\Working\tools\jython\jython2.5.3b1\jython.
jar;C:\Working\tools\maven\repository2\tools\tools-core\1.3.1-SNAPSHOT\tools-core-
1.3.1-SNAPSHOT.jar org.python.util.jython -m test
test.py


This is jy.bat just to show there is nothing weird there. Jython 2.5.2 was the version disted with the robot framework.

rem set JYTHON=%M2_REPO%\org\robotframework\robotframework\2.7.1\robotframework-
2.7.1.jar
set JYTHON=C:\Working\tools\jython\jython2.5.3b1\jython.jar


java -classpath %JYTHON%;%M2_REPO%\ets\tools-core\1.3.1-SNAPSHOT\tools-core-1.3.
1-SNAPSHOT.jar org.python.util.jython %1 %2 %3
msg7124 (view) Author: Darjus Loktevic (darjus) Date: 2012-05-21.19:57:41
Hey Adam,

Where is this editor.vimgen coming from? I am trying to reproduce your issue, but can't. I agree that get_code is missing, but first of all i want to make sure we can reproduce your problem.

Could you build a test that reproduces it (or at least clarify a bit more on reproducing it)?

java -cp ./dist/robotframework-trunk20120521.jar org.python.util.jython -m robot.run                                                    
[ ERROR ] Expected at least 1 argument, got 0.

Thanks!
Darjus
msg7144 (view) Author: Adam (conflatedauto) Date: 2012-05-25.00:02:47
Hi Darjus ā€“ thanks for looking into this. The vimgen.py script is inside the tools-core jar ā€“ I can see how it would be ambiguous without a jar listing now. Tools-core is part of the internal project Iā€™m working on.
 
$ jar tfv tools-core-1.3.2.jar
     0 Sun May 06 23:18:56 CST 2012 META-INF/
  127 Sun May 06 23:18:54 CST 2012 META-INF/MANIFEST.MF
     0 Sun May 06 23:18:34 CST 2012 editor/
   630 Sun May 06 23:18:34 CST 2012 editor/nameutil.py
     0 Sun May 06 23:18:34 CST 2012 editor/__init__.py
  7381 Sun May 06 23:18:34 CST 2012 editor/vimgen.py
 
Does that help?
Adam
History
Date User Action Args
2013-02-19 21:50:47fwierzbickisetnosy: + fwierzbicki
versions: + Jython 2.5, - 2.5.2, 2.5.3b2
2012-05-25 00:02:47conflatedautosetmessages: + msg7144
2012-05-21 19:57:41darjussetnosy: + darjus
messages: + msg7124
2012-04-30 08:37:52conflatedautocreate