Changes between Version 55 and Version 56 of pyson


Ignore:
Timestamp:
09/09/21 14:22:24 (3 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pyson

    v55 v56  
    5757The following types are recognised and handled separately:
    5858
    59 NoneType, int, float, bool, str, complex, range, bytes, bytearray, datetime, [https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/wiki/uri URI], UUID, Decimal, dict, list
     59NoneType, int, float, bool, str, complex, range, bytes, bytearray, datetime, [https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/wiki/uri URI], UUID, Decimal, dict, list, Exceptions (see below)
    6060
    6161The dict and list are treated even more special as we also support the List[TYPE] and Dict[KEYTYPE, VALUETYPE] types.
     
    6464
    6565You can use {{{ Union[X, NoneType] }}} where {{{NoneType=type(None)}}} if the object can also be None. So for exmple you can use {{{reservationBid:Union[Bid,type(None)] = None}}}. Do not use the mypy.NoneType which is an entirely different class. We do not support {{{ Union[X,Y] }}} where both X and Y are not NoneType.
     66
     67===Exceptions
     68Exceptions are handled as follows:
     69Serialization of an exception gives {{{ {"message":"...", "cause": EX, "stackTrace":[]} }}} where EX is either None or another serialized exception. This format tries to maximize compatibility with the jackson way of serializing exceptions. The "stackTrace" field is always empty because python does not include the stacktrace with exceptions; it's there only for compatibility of the format with java. Note that the type of the exception is not included (as in jackson).
     70Deserialization takes a dict with at least a "message" field. The constructor of the provided class is called with this message, so make sure that your exception constructor takes the message as the constructor argument. If the dict contains a cause, the cause is also parsed recursively, as general Exception, and attribute {{{__cause__}}} of the exception is filled with the result.
    6671
    6772== Annotations