Issue1956

classification
Title: cannot import twisted module
Type: behaviour Severity: major
Components: Core Versions: Jython 2.7
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: Arfrever, amak, fwierzbicki, glyph, thijs
Priority: high Keywords: twisted

Created on 2012-08-08.12:43:38 by thijs, last changed 2013-09-16.22:22:40 by thijs.

Messages
msg7354 (view) Author: Thijs Triemstra (thijs) Date: 2012-08-08.12:43:37
For some reason it's not possible to import modules from twisted.scripts with jython, cpython's working fine. This is using Twisted 12.1+.

$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.scripts import trial
>>>

$ jython
Jython 2.7.0a2+ (default:96bc2fa235a0, Aug 8 2012, 14:26:20) 
[OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_24
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.scripts import trial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name trial
>>>
msg7443 (view) Author: Alan Kennedy (amak) Date: 2012-08-28.21:24:28
When I checkout the twisted trunk and try to run it with cpython (without having done a proper setup.py install), I get the following error

C:\>C:\Python27\python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from twisted.scripts import trial
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\temp\trunk\twisted\scripts\trial.py", line 9, in <module>
    from twisted.internet import defer
  File "C:\temp\trunk\twisted\internet\defer.py", line 25, in <module>
    from twisted.python import log, failure, lockfile
  File "C:\temp\trunk\twisted\python\log.py", line 17, in <module>
    from zope.interface import Interface
ImportError: No module named zope.interface
>>> ^Z

And I see that we have an issue in our bug tracker for zope.interface, related to pyopenssl, although I don't know if that is the cause of this problem.

Issue with zope.interface
http://bugs.jython.org/issue1195

Does zope.interface run on jython? Are you using other parts of twisted successfully on jython?

Here is a blog post from 2008 (by Martijn Faassen) discussing porting zope.interface to jython.

http://faassen.n--tree.net/blog/view/weblog/2008/04/14/0

Although I don't know what the status of that effort is?

This Twisted ticket says that jython support was removed in 2009

http://twistedmatrix.com/trac/ticket/3725

I don't know if it's been reinstated?

I think you should contact the twisted folks and ask them if they expect twisted to run on jython, and if they do, which bits of it?

If you do contact them, please post a link on this ticket.
msg7446 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-08-28.21:52:33
Alan: thanks for giving it a try!

The twisted folks are having a monthly meetup local to me (Glyph lives here now) I haven't made it to one yet due to being out of town every time - but I plan on making one soon where I'll see if I can shed light on this.
msg7447 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-08-28.21:53:53
BTW nriley fixed all of the zope.interface issues several years ago. If it hasn't bit rotted that shouldn't be the issue.
msg7450 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2012-08-28.22:11:53
About 98.4% of tests of zope.interface-4.0.1 pass with recent snapshot of Jython 2.7:
"Ran 1341 tests in 10.980s

FAILED (failures=7, errors=14)"

http://twistedmatrix.com/trac/wiki/TwistedMatrixLaboratories says that Thijs Triemstra is one of Twisted developers :) .
msg7712 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-20.00:16:48
Drat I really need to make it to one of the twisted sprints soon.
msg8118 (view) Author: Thijs Triemstra (thijs) Date: 2013-09-16.22:22:39
One mysterious traceback I'm seeing is the following (tested with python2.7b1 and twisted 13.1+ installed using jython setup.py develop). The related twisted ticket for jython support is: https://twistedmatrix.com/trac/ticket/3413

$ /home/thijs/Downloads/jython2.7b1/bin/trial twisted.python
Traceback (most recent call last):
  File "/home/thijs/Downloads/jython2.7b1/bin/trial", line 8, in <module>
    execfile(__file__)
  File "/home/thijs/Downloads/jython2.7b1/bin/trial", line 8, in <module>
    execfile(__file__)
  File "/home/thijs/workspaces/opensource/software/twisted/svn/Twisted/branches/jython-3413-3/bin/trial", line 7, in <module>
    import _preamble
  File "/home/thijs/workspaces/opensource/software/twisted/svn/Twisted/branches/jython-3413-3/bin/trial", line 7, in <module>
    import _preamble
java.lang.ArrayIndexOutOfBoundsException: 6482
	at org.python.objectweb.asm.ClassReader.readClass(Unknown Source)
	at org.python.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.python.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.python.core.AnnotationReader.<init>(AnnotationReader.java:46)
	at org.python.core.imp.readCode(imp.java:219)
	at org.python.core.imp.createFromPyClass(imp.java:185)
	at org.python.core.imp.createFromPyClass(imp.java:177)
	at org.python.core.imp.loadFromSource(imp.java:590)
	at org.python.core.imp.find_module(imp.java:480)
	at org.python.core.imp.import_next(imp.java:737)
	at org.python.core.imp.import_module_level(imp.java:846)
	at org.python.core.imp.importName(imp.java:936)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1278)
	at org.python.core.PyObject.__call__(PyObject.java:373)
	at org.python.core.__builtin__.__import__(__builtin__.java:1231)
	at org.python.core.imp.importOne(imp.java:955)
	at org.python.pycode._pyx23.f$0(/home/thijs/workspaces/opensource/software/twisted/svn/Twisted/branches/jython-3413-3/bin/trial:18)
	at org.python.pycode._pyx23.call_function(/home/thijs/workspaces/opensource/software/twisted/svn/Twisted/branches/jython-3413-3/bin/trial)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1302)
	at org.python.core.__builtin__.execfile_flags(__builtin__.java:518)
	at org.python.core.__builtin__.execfile(__builtin__.java:495)
	at org.python.core.__builtin__.execfile(__builtin__.java:526)
	at org.python.core.BuiltinFunctions.__call__(__builtin__.java:88)
	at org.python.core.PyObject.__call__(PyObject.java:407)
	at org.python.pycode._pyx2.f$0(/home/thijs/Downloads/jython2.7b1/bin/trial:10)
	at org.python.pycode._pyx2.call_function(/home/thijs/Downloads/jython2.7b1/bin/trial)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1302)
	at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:235)
	at org.python.util.jython.run(jython.java:308)
	at org.python.util.jython.main(jython.java:137)

java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: 6482
History
Date User Action Args
2013-09-16 22:22:40thijssetnosy: + glyph
messages: + msg8118
2013-02-20 00:16:48fwierzbickisetpriority: high
resolution: remind
messages: + msg7712
versions: + Jython 2.7, - 2.7a2
2012-08-28 22:11:53Arfreversetmessages: + msg7450
2012-08-28 21:53:53fwierzbickisetmessages: + msg7447
2012-08-28 21:52:33fwierzbickisetassignee: fwierzbicki
messages: + msg7446
2012-08-28 21:24:29amaksetmessages: + msg7443
2012-08-25 21:09:44amaksetnosy: + amak
2012-08-11 10:43:29Arfreversetnosy: + Arfrever
2012-08-08 17:51:56fwierzbickisetkeywords: + twisted
nosy: + fwierzbicki
2012-08-08 12:43:38thijscreate