Changes in Brython version 20131109-150256 ========================================== Hi, It is with a great pleasure that I announce the release of Brython 1.2, which is now available for download on the development site, and uploaded to the Brython site at www.brython.info The changes are detailed in the changelog below This version brings minor backwards-incompatible changes : ajax and websocket must be imported as modules, the query string is an attribute of doc and not a method, objects created by object() can no longer receive attributes It fixes some of the issues reported on the development site. All the internal tests work, but it's highly probable that this version brings a few regressions compared to the last stable release. In this case, please report them on the Bitbucket tracker Many thanks to the developer team and to you all for your inputs and support - Pierre Changelog for Brython 1.2 ------------------------- Classes implementation and attribute lookups ============================================ This version brings a major change in class implementations in Brython In the previous version, when a class instance was created, the Javascript object for this instance had attributes made from the class attributes : if the class defined a method foo, the instance has an attribute 'foo' It made basic attribute lookup fast : instance.foo was found as the attribute 'foo' of the Javascript object. It was more difficult for attributes defined in subclasses of the class. But it made it impossible to reflect any change made to the class in already created instances For instance, a bug that was never reported : def foo: A = 0 x = foo() foo.A = 1 print(x.A) printed 0 in the previous versions The new version applies the same attribute resolution algorithm as Python : search in the instance dictionary first, then in the class attributes, then in the parent classes, using the Method Resolution Order built from the parent classes using the C3 algorithm The Python code 'obj.x' is translated into 'getattr(obj,'x')'. getattr() resolves attributes using the object's method __getattribute__ first, else __getattr__. If an attribute is a descriptor (ie implements the method __get__) it is resolved as specified in the Python reference, with a distinction between data and non-data descriptors A Python class is now represented by 2 Javascript objects : - a 'factory' function, used to create instances of the class : it is defined using the class methods __new__ and __init__ - a class 'dictionary' : a Javascript object whose attributes are the class attributes and methods Backwards-incompatible changes ============================== - interface for the query string : attribute doc.query instead of function doc.query() - ajax and websockets are now in modules, not built-in : import ajax req = ajax.ajax() import websocket ws = websocket.websocket() Bug fixes ========= - issue 142 : isinstance(obj,klass) checks parent classes of obj - issue 143 : Brython site mirror available at zip format - issue 145 : sorted() not working - issue 148 : bug in json - issue 149 : raise UnboundLocalError for local variables referenced before assignment - issue 154 : ajax.send() accepts string arguments (supposed to be JSON data) - issue 155 : JSObject accepts arguments that are themselves instances of JSObject or JSContructor - attributes can no longer be set to instances created by object() Minor implementation changes ============================ - most built-in classes are now in separate files (py_int, py_float, py_dict, py_set), built-in functions are in py_builtin_functions (all was mixed in py_classes in previous versions) - use the same base functions $iterator and $iterator_class for iterators on lists, tuples, dicts, sets, dict keys, values and items, etc New features ============ - implement __doc__ attribute for modules, functions and classes - implement __name__ and __file__ for modules - manage call stack and use it in error reporting - improved French and English documentation - new recipe for form validation