python-sutime icon indicating copy to clipboard operation
python-sutime copied to clipboard

Upgrade to jpype1 lib causing crashing issue with SUTime

Open speechwrecko opened this issue 3 years ago • 2 comments

During a recent deploy the jpype1 lib was automatically updated and our systems integrated with SUTime started to crash with the following exception:

TypeError json in loads error the JSON object must be str, bytes or bytearray, not 'java.lang.String'.

The issue occurs in line 159 of the sutime.py file return json.loads(self._sutime.annotate(input_str, reference_date))

            call.
    """
    if not jpype.isThreadAttachedToJVM():
        jpype.attachThreadToJVM()
    if reference_date:
        return json.loads(self._sutime.annotate(input_str, reference_date))
    return json.loads(self._sutime.annotate(input_str))

speechwrecko avatar Aug 05 '20 18:08 speechwrecko

Note we mitigated the issue by pinning an older version of the lib

speechwrecko avatar Aug 05 '20 18:08 speechwrecko

This library appears to pretty far out of date. The solution is to insert "str()" as Java returns a Java string not a Python one. Apparently json library is not duck typing to get the contents of the Java string.

Thrameos avatar Aug 05 '20 21:08 Thrameos