1. On behalf of the Jython development team, I'm pleased to announce that the final release of Jython 2.5.3 is available. I'd like to thank Adconion Media Group for sponsoring my work on Jython. I'd also like to thank the many contributors to Jython.

    This release is being entirely hosted at maven central. The traditional installer can be found here. See the installation instructions for using the installer. Three other versions are available:
    To see all of the files available including checksums, go here.

    This release fixes numerous bugs since the 2.5.2 release of Jython. Some highlights include:


    •  File uploads where broken in Tomcat and Jetty.
    •  Imports sometimes blew the stack. This was seen in SQLAlchemy for example.
    •  Some race conditions and threading issues where fixed.
    •  Several JSR 223 problems have been fixed.


    See the NEWS file for details.

    Please report any bugs that you find. Thanks!
    12

    View comments

  2. On behalf of the Jython development team, I'm pleased to announce that the first release candidate of Jython 2.5.3 is available. I'd like to thank Adconion Media Group for sponsoring my work on Jython. I'd also like to thank the many contributors to Jython.

    For the first time this release is being entirely hosted at maven central. The traditional installer can be found here. See the installation instructions for using the installer. Three other versions are available:

    To see all of the files available including checksums, go here.

    Jython 2.5.3 fixes numerous bugs, see the NEWS file for details.

    Please report any bugs that you find. Thanks!
    3

    View comments

  3. On behalf of the Jython development team, I'm pleased to announce that Jython 2.7 alpha2 is available for download. See the installation instructions.

    I'd like to thank Adconion Media Group for sponsoring my work on Jython 2.7. I'd also like to thank the many contributors to Jython. Jython 2.7 alpha2 fixes a serious bug where site-packages failed to appear in the path. There are still some missing features, in particular bytearray and the io system are currently incomplete.
    Please report any bugs that you find. Thanks!
    14

    View comments

  4. On behalf of the Jython development team, I'm pleased to announce that Jython 2.7 alpha1 is available for download. See the installation instructions.

    I'd like to thank Adconion Media Group for sponsoring my work on Jython 2.7. I'd also like to thank the many contributors to Jython. Jython 2.7 alpha1 implements much of the functionality introduced by CPython 2.6 and 2.7. There are still some missing features, in particular bytearray and the io system are currently incomplete.
    Please report any bugs that you find. Thanks!
    19

    View comments

  5. I now have a contract with Adconion Media Group to produce a 2.7 version of Jython by July 15 of this year. It all started when my colleague Miki Tebeka asked how long it was going to be before a Jython 2.7 was going to become available. At the time I did not have a very happy answer to that one. Adconion has an internal application that will use Jython and they have standardized on the 2.7 version of Python for their CPython development. Naturally it's a pain to go back to 2.5 when you are happy with 2.7. One thing led to another and now I get to spend all of my time thinking about Jython for a while again. This time there is the added bonus of helping out with a Jython application going into production. I'll post more about that application another time :)
    13

    View comments

  6. On behalf of the Jython development team, I'm pleased to announce that Jython 2.5.3 beta1 is available for download. See the installation instructions.

    Jython 2.5.3 fixes a number of bugs, including some errors when using relative imports. Please see the NEWS file for detailed release notes.

    Please report any bugs that you find. Thanks!
    0

    Add a comment

  7. Releases of Python (and so releases of Jython) sometimes add new built-in types. In 2.6, a new such buitin is the "bytes" type. In the 2.x series, "bytes" is just a synonym for "str". In 3.x "bytes" is the name used for 8 bit strings while "str" is a unicode string (and so the "unicode" type disappears in 3.x). This will make it a great example for adding a builtin since there is no added functionality to obscure the basics.

    First we'll verify that no bytes builtin exists at this time:


    [frank jython]$ ./dist/bin/jython
    Jython 2.6a0+ (default:9c9c311c201b, Feb 10 2012, 10:29:32)
    [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_23
    Type "help", "copyright", "credits" or "license" for more information.
    >>> bytes('foo')
    Traceback (most recent call last):
    File "", line 1, in
    NameError: name 'bytes' is not defined


    Next we'll look in src/org/python/core/__builtin__.java and add the following:


    [frank jython]$ hg diff
    diff --git a/src/org/python/core/__builtin__.java b/src/org/python/core/__builtin__.java
    --- a/src/org/python/core/__builtin__.java
    +++ b/src/org/python/core/__builtin__.java
    @@ -305,6 +305,7 @@
    dict.__setitem__("Ellipsis", Py.Ellipsis);
    dict.__setitem__("True", Py.True);
    dict.__setitem__("False", Py.False);
    + dict.__setitem__("bytes", PyString.TYPE);


    Since this is just an alias to an existing type, we just needed to point it at the type in builtins. Note that the same entry for "str" is:


    dict.__setitem__("str", PyString.TYPE);


    So this particular addition to builtin is particularly simple (just one line). Normally we would have needed to implement a new type, which would have been a much bigger change.

    And now we'll try it out:


    [frank jython]$ ./dist/bin/jython
    *sys-package-mgr*: processing modified jar, '/home/frank/hg/jython/jython/dist/jython-dev.jar'
    Jython 2.6a0+ (default:9c9c311c201b+, Feb 13 2012, 09:52:10)
    [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_23
    Type "help", "copyright", "credits" or "license" for more information.
    >>> x = bytes('foo')
    >>> x
    'foo'
    >>> type(x)
    <type 'str'>


    And there you go!
    0

    Add a comment

  8. One of my new years resolutions is to make Jython more friendly to new developers. One way to do that is to write up some notes on bits of Jython that are particularly mysterious to newcomers. I've boldly titled this post "Jython dev notes part I" to push myself to create more than one of these :)

    It should be noted that I'm not shying away from making these notes highly technical - but I'm happy to edit them to make them more manageable later. Hopefully if I write enough of these up they can make up the beginnings of an advanced dev guide for Jython.

    Recently I was asked how the Jython exposer works. The Jython exposer is the code that exposes the types that are written in Java as Python types in the Jython interpreter. It does this by rewriting the .class files during build time and adding the special methods that are seen at runtime. The augmented .class files end up in the build/exposed/ directory, and are ultimately built into the jython.jar distribution file. You can run the exposer from the Jython source like so:

    ant expose


    The exposer reads through each of the classes listed in CoreExposed.include and rewrites each of them. The rewritten classes get new methods generated for the Jython runtime to use as Python classes and methods. The exposer finds the code that it needs to operate on by finding Java annotations that have been defined for this purpose. An example is the easiest way to explain:

    The string type in Python is called "str" and is implemented in Jython by src/org/python/core/PyString.java -- at the top of PyString.java is:


    @ExposedType(name = "str", doc = BuiltinDocs.str_doc)


    Which tells the exposer to expose PyString.java as the "str" type and take its "__doc__" attribute from BuiltinDocs.str_doc. Note that there currently appears to be a bug that str.__doc__ ends up as None right now, but it will show up if you run:


    >>> help(str)


    Further down in the source of PyString.java:


    @ExposedNew
    static PyObject str_new(PyNewWrapper new_, boolean init, PyType subtype, ...


    Exposes the str_new Java method as the Python str __new__ method. (The __new__ method is a special class level method that acts as a str factory).

    Next we'll look at some examples of ExposedMethod, which is the most common annotation that the exposer uses. ExposedMethod exposes general methods for Python classes.


    @ExposedMethod(doc = BuiltinDocs.str___len___doc)
    final int str___len__() {


    The above code exposes the __len__ method, which is how the str method will respond to a call to the builtin len() function. Since the object itself is the only argument, the ExposedMethod annotation only needs a doc.


    @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.str___eq___doc)
    final PyObject str___eq__(PyObject other) {


    The above exposes the __eq__ method. MethodType.Binary indicates that this is a binary method that will take 2 arguments. The exposer has special handling for common types like this.


    @ExposedMethod(defaults = {"null", "-1"}, doc = BuiltinDocs.str_split_doc)
    final PyList str_split(String sep, int maxsplit) {


    The above implements the split method of str, which takes 2 optional arguments. the "defaults" attribute assigns default values to the optional arguments.

    There is much more to the exposer, but unfortunately the code is the only real documentation other than this post at this time. The source for the exposer engine is in:

    src/org/python/expose/

    And the source for the generator and ant task are here:

    src/org/python/expose/generate/
    1

    View comments

About Me
About Me
Subscribe
Subscribe
Links
Blog Archive
Blog Roll
Blog Roll
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.