[
https://issues.apache.org/jira/browse/TINKERPOP-3275?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ken Hu updated TINKERPOP-3275:
------------------------------
Description:
Caveat: I haven't fully verified this, just something AI told me when I was
updating the "model" tests for gremlin-python. Just putting here so it can be
checked later.
gremlin-python can't serialize BigInt signed boundary values like -129.
{code:java}
The failure path is:
GraphBinaryWriter.write_object()
BigIntIO.dictify()
BigIntIO.write_bigint()
obj.to_bytes(length, byteorder='big', signed=True)
{code}
For -129, Python reports:
(-129).bit_length() == 8
The current writer computes:
length = (obj.bit_length() + 7) // 8 # 1
But one signed byte only represents -128 through 127, so -129 needs two bytes
in two’s complement form. The serializer is using magnitude bit length as if it
were signed encoded length.
was:
Caveat: I haven't fully verified this, just something AI told me when I was
writing the "model" tests for gremlin-go. Just putting here so it can be
checked later.
gremlin-python can't serialize BigInt signed boundary values like -129.
{code:java}
The failure path is:
GraphBinaryWriter.write_object()
BigIntIO.dictify()
BigIntIO.write_bigint()
obj.to_bytes(length, byteorder='big', signed=True)
{code}
For -129, Python reports:
(-129).bit_length() == 8
The current writer computes:
length = (obj.bit_length() + 7) // 8 # 1
But one signed byte only represents -128 through 127, so -129 needs two bytes
in two’s complement form. The serializer is using magnitude bit length as if it
were signed encoded length.
> gremlin-python graphbinary BigInt serializer incorrect for negative boundary
> values
> -----------------------------------------------------------------------------------
>
> Key: TINKERPOP-3275
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3275
> Project: TinkerPop
> Issue Type: Bug
> Components: python
> Affects Versions: 3.7.6, 3.8.1
> Reporter: Ken Hu
> Priority: Major
>
> Caveat: I haven't fully verified this, just something AI told me when I was
> updating the "model" tests for gremlin-python. Just putting here so it can be
> checked later.
> gremlin-python can't serialize BigInt signed boundary values like -129.
> {code:java}
> The failure path is:
> GraphBinaryWriter.write_object()
> BigIntIO.dictify()
> BigIntIO.write_bigint()
> obj.to_bytes(length, byteorder='big', signed=True)
> {code}
> For -129, Python reports:
> (-129).bit_length() == 8
> The current writer computes:
> length = (obj.bit_length() + 7) // 8 # 1
> But one signed byte only represents -128 through 127, so -129 needs two bytes
> in two’s complement form. The serializer is using magnitude bit length as if
> it were signed encoded length.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)