Jython support

Oct 3, 2013 at 4:27 PM
Edited Oct 3, 2013 at 5:25 PM
I'm trying to get Jython working with visual studio but not having much success. Has anyone had this working?

I have tried Jython 2.5.3 and 2.7b1. I set my interpreter path to the jython.bat file, eg: C:\jython2.7\jython.bat

First, I was getting an error:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_launcher.py", line 21, in <module>
import visualstudio_py_debugger
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_debugger.py", line 336, in <module>
attach_lock = thread.allocate()
AttributeError: type object 'org.python.modules.thread.thread' has no attribute 'allocate'
I changed thread.allocate() to thread.allocate_lock() since it appears to be what was intended (is this a bug fix?)

After the change, I get a new error message:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_launcher.py", line 73, in <module>
visualstudio_py_debugger.debug(file,
File "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_debugger.py", line 1967, in debug
cur_thread.stepping = STEPPING_LAUNCH_BREAK
AttributeError: 'NoneType' object has no attribute 'stepping'
EDIT: some more information
it seems that the debugger_thread_id is None. for the code on line visualstudio_py_debugger.py:1718
# start the debugging loop
global debugger_thread_id
debugger_thread_id = _start_new_thread(DebuggerLoop(conn).loop, ()
simple print statements give:
debugger_thread_id = None
_start_new_thread = <java function start_new_thread 0x2>
Coordinator
Oct 4, 2013 at 11:49 PM
thanks for reporting this - we're looking into it right now.
Oct 5, 2013 at 4:57 AM
Thanks. I'd like to get this working - let me know if I can help.
Coordinator
Oct 7, 2013 at 4:50 PM
So while there are certainly some problems you won't be able to fix without rebuilding PTVS, you can edit visualstudio_py_debugger.py to your heart's content (no need to restart VS in between changes either - you can edit it in VS and then test it immediately).

We obviously started using some thread-related functionality that doesn't exist in Jython. It may just be a case of switching to a name that CPython, IronPython and Jython all recognise, or possibly some more sys.platform checks.

Rest assured that we will get to this eventually - we did not intend to drop Jython support, though it looks like we'll have to officially drop it for 2.0. If you get it working (and/or make it work better) we're very willing to accept contributions.