fix reader for large longs
MODIFY
fastavro/_read.pyx
fastavro/_read.pyx
@@ -219,7 +219,7 @@ cpdef long64 read_long(ReaderBase fo,
"""int and long values are written using variable-length, zig-zag
coding."""
cdef ulong64 b
- cdef long64 n
+ cdef ulong64 n
cdef int32 shift
cdef bytes c = fo.read(1)

MODIFY
tests/test_fastavro.py
tests/test_fastavro.py
@@ -1368,3 +1368,21 @@ def test_schema_is_custom_dict_type():
new_file.seek(0)
new_record = fastavro.schemaless_reader(new_file, other_type_schema)
assert record == new_record
+
+
+def test_long_bounds():
+ schema = {
+ 'name': 'test_name',
+ 'namespace': 'test',
+ 'type': 'record',
+ 'fields': [
+ {'name': 'time', 'type': 'long'},
+ ],
+ }
+
+ records = [
+ {'time': (1 << 63) - 1},
+ {'time': -(1 << 63)},
+ ]
+
+ assert records == roundtrip(schema, records)

fix reader for large longs