protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

import of protobuf fails in Jython 2.7.2

Open AdamElliott-AB opened this issue 5 years ago • 2 comments

https://github.com/protocolbuffers/protobuf/blob/92e3d3e02a886839c75aca74dab4d0ea4cef8eb8/python/google/protobuf/internal/decoder.py#L92

from yamcs.client import YamcsClient Traceback (most recent call last): File "", line 1, in File "/home/jython/jython2.7.2/Lib/site-packages/yamcs/client.py", line 4, in from google.protobuf import timestamp_pb2 File "/home/jython/jython2.7.2/Lib/site-packages/google/protobuf/timestamp_pb2.py", line 7, in from google.protobuf import reflection as _reflection File "/home/jython/jython2.7.2/Lib/site-packages/google/protobuf/reflection.py", line 51, in from google.protobuf import message_factory File "/home/jython/jython2.7.2/Lib/site-packages/google/protobuf/message_factory.py", line 49, in from google.protobuf.internal import python_message as message_impl File "/home/jython/jython2.7.2/Lib/site-packages/google/protobuf/internal/python_message.py", line 64, in from google.protobuf.internal import decoder File "/home/jython/jython2.7.2/Lib/site-packages/google/protobuf/internal/decoder.py", line 92, in _SURROGATE_PATTERN = re.compile(six.u(r'[\ud800-\udfff]')) File "/home/jython/jython2.7.2/Lib/site-packages/six.py", line 658, in u return unicode(s.replace(r'\', r'\\'), "unicode_escape") UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 1-7: illegal Unicode character

Jython doesn't support lone surrogates at all. According to https://bugs.jython.org/issue2048 that is by design.

AdamElliott-AB avatar Aug 03 '20 19:08 AdamElliott-AB

We'd be happy to accept a PR to address this.

perezd avatar Oct 22 '20 20:10 perezd

Another place where Jython hits this is in https://github.com/protocolbuffers/protobuf/blob/master/python/google/protobuf/json_format.py#L82

    r'[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]'

rasantel avatar Nov 13 '20 22:11 rasantel

Closing since I don't believe we actively support Jython. We're happy to accept PRs for a contributed fix though.

zhangskz avatar Sep 01 '22 19:09 zhangskz

@AdamElliott-AB @rasantel hi guys, have you found a way to slove this?

JesseBlackman avatar Nov 17 '22 03:11 JesseBlackman

Not I. I ended up reworking my architecture so Jython wasn't needed. This issue made it too much of a hassle for me.

AdamElliott-AB avatar Nov 17 '22 12:11 AdamElliott-AB