Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

The PythonActor uses Jython and not all of Python is supported by the version of Jython that ships with BCVTB and Ptolemy II. It looks like it is fairly old:

bash-3.2$ svn log $PTII/lib/jython.jar
------------------------------------------------------------------------
r70691 | hudson@moog.eecs.berkeley.edu | 2014-11-21 08:32:29 -0800 (Fri, 21 Nov 2014) | 1 line

Updated to Jython 2.5.4-rc1

Jython 2.7.0 is supposed to support all of what is in the C version of Python 2.7.

The Jython 2.7.0 jar file is 37Mb, which is an increase from the Jython 2.5.4-rc1 size of 10Mb. I replaced $PTII/lib/jython.jar with the 2.7.0 jar file and the tests passed

wget -O jython.jar http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar
mv jython.jar $PTII/lib/jython.jar
cd $PTII/ptolemy/actor/lib/python/test/
make

Perhaps try updating your copy of jython.jar and then see if the with statement works.

I committed an updated version of jython.jar to the ptII tree, so I'll see what breaks in the tests over the next few days.