fix(python): read legacy TYPE_INT64 marshal values

Fixes #6609
This commit is contained in:
morluto committed 2026-10-23 19:07:45 +08:00
1 parent 0d44afed7e
commit d0a8e3c60d
3 files changed
+215

No files matched your search

+13
View File
@@ -26,6 +26,7 @@ const TYPE_TRUE = 0x54;
const TYPE_STOPITER = 0x53;
const TYPE_ELLIPSIS = 0x2e;
const TYPE_INT = 0x69;
const TYPE_INT64 = 0x49;
const TYPE_FLOAT_TEXT = 0x66;
const TYPE_FLOAT = 0x67;
const TYPE_COMPLEX_TEXT = 0x78;
@@ -390,6 +391,10 @@ class MarshalReader {
const value = BigInt(this.i32());
return { kind: "int", value, bits: smallBitLength(value) };
}
case TYPE_INT64: {
const value = this.i64();
return { kind: "int", value, bits: smallBitLength(value) };
}
case TYPE_FLOAT_TEXT:
return { kind: "float", value: this.textFloat() };
case TYPE_FLOAT:
@@ -1514,6 +1519,14 @@ class MarshalReader {
return value;
}
i64(): bigint {
if (this.offset > this.bytes.length - 8)
malformed("Marshal stream ended inside a 64-bit integer.");
const value = this.bytes.readBigInt64LE(this.offset);
this.offset += 8;
return value;
}
/** CPython `r_long` count fields that its constructors require non-negative. */
nonNegativeInt32(field: string): number {
const value = this.i32();