Difference: JythonUpgrade (6 vs. 7)

Revision 72011-11-18 - JorgoBakker

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Upgrade to Jython 2.5

Deleted:
<
<

 Up to HIPE 7, we have been using the Jython 2.1 library, which mostly uses the syntax of Python 2.1
Starting from HIPE 8 we will upgrade to Jython 2.5, which uses the same syntax rules as Python 2.5.

In most cases, your scripts will run fine; however, in certain cases you may need to adapt them. This page lists the known differences between Jython 2.1 and Jython 2.5

Added:
>
>

 

Wrong locations of global import statements

Changed:
<
<
You may have written code where global import statements are done within a Jython function.
>
>
You may have written code where global import statements are done within a Jython function.
 As of Jython 2.5, this is not allowed anymore (in fact, it was not allowed in Python 2.1 but Jython 2.1 inadvertently allowed for it).

When executing the code against Jython 2.5, you will get messages such as:

Line: 59 to 59
 

Known jython module changes

Added:
>
>
The following modules changed their names:
 
Jython 2.1 Jython 2.5
import javaos import os

Known jython behavioral changes

Added:
>
>
 

__name__


Line: 89 to 92
 

TODO (verify): If you always want the full name, use: Bar.getFastName()

Added:
>
>
 

Numeric types

Added:
>
>
  In Jython 2.1 numeric types were Py objects like PyInteger or PyFloat and as such had methods like toString(). In Jython 2.5 numeric types are more like native types and do not have these basic Object methods available. The difference was discovered when passing an integer into a jython function and then printing this value using the toString() method. In Jython 2.5 this results in the following error:
  <type 'exceptions.AttributeError'>: 'int' object has no attribute 'toString'
Line: 131 to 136
 
  • Add a float literal to the expression ( + 0.0 )
  • Use an explicit cast to float (float(i))
Added:
>
>
 
 
This site is powered by the TWiki collaboration platform Powered by Perl