on Jython

Saturday 22 May 2010This is 13 years old. Be careful.

Someone asked me recently whether works on Jython. I had never tried it before, so I took a look. works in two steps: first, execute the code and record line numbers executed. Then analyze the code to identify parts that could have been executed but weren’t. It turns out Jython provides the tool needed for the first (sys.settrace), but not the tools needed for the second (code.co_consts, and other internal representations of compiled code).

I was able to measure a Jython execution by running “coverage run” under Jython 2.5.1 to do the first step. Then I ran “coverage html” under CPython to complete the second step and get a report.

But I don’t know if the line numbers will match up perfectly if the two steps are run under different interpreters. I’m looking for someone with a real Jython code base who’d like to try this technique and tell me what they find. Take the tip of the bitbucket repository, install it into your Jython and CPython installations, and run the two commands under the two different interpreters.

Drop me a line if you try this out, I’d love to be able to support Jython with


Thanks Ned, for the followup and for organizing the meetup in the first place. Any word on if the audio turned out OK? Stephan sent around his slides which was nice, but about half the night (and the real good stuff) was war stories from the Q&A.
If the recording pass of works when you just have sys.settrace, then it should also be able to handle IronPython as well under exactly the same constraints.

I shall have to give that a try.
I tried IronPython, and found that it doesn't support setuptools, so I couldn't get installed.
Ned, I was wondering if you've heard any additional word on Jython or IronPython support. Both projects have had a release in the past 10 days, which has prompted me to install them, and I'd sure like to generate a coverage report for two of my projects that accumulates information from CPython 2.4 through 2.7 as well as the latest Jython and IronPython releases!

I've said it before, but I'll say it again: thanks for your work on coverage. It's a marvelous tool that's really helped me identify problem areas in the software I work on.
Ned, I am trying to get coverage setup on jython 2.5.2. My references to java.util.Date. It compiles and runs when I use jython interpretor. It fails when I try to run "coverage run"

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.