You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ni...@apache.org on 2023/02/17 13:06:44 UTC
[avro] 02/02: AVRO-3715: [Python] Fix type issues
This is an automated email from the ASF dual-hosted git repository.
nielsbasjes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
commit 72e38dc8ff4b78ad7c66e002208d404669f94ac8
Author: Niels Basjes <ni...@basjes.nl>
AuthorDate: Fri Feb 17 11:49:24 2023 +0100
AVRO-3715: [Python] Fix type issues
---
lang/py/avro/io.py | 4 ++--
lang/py/avro/test/test_io.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lang/py/avro/io.py b/lang/py/avro/io.py
index 998dcd863..7b5576697 100644
--- a/lang/py/avro/io.py
+++ b/lang/py/avro/io.py
@@ -482,7 +482,7 @@ class BinaryEncoder:
signed long is 8, 8 bytes are written.
"""
sign, digits, exp = datum.as_tuple()
- if (-1 * exp) > scale:
+ if (-1 * int(exp)) > scale:
raise avro.errors.AvroOutOfScaleException(scale, datum, exp)
unscaled_datum = 0
@@ -508,7 +508,7 @@ class BinaryEncoder:
Decimal in fixed are encoded as size of fixed bytes.
"""
sign, digits, exp = datum.as_tuple()
- if (-1 * exp) > scale:
+ if (-1 * int(exp)) > scale:
raise avro.errors.AvroOutOfScaleException(scale, datum, exp)
unscaled_datum = 0
diff --git a/lang/py/avro/test/test_io.py b/lang/py/avro/test/test_io.py
index 8c92af0fa..b77c17fb9 100644
--- a/lang/py/avro/test/test_io.py
+++ b/lang/py/avro/test/test_io.py
@@ -504,7 +504,7 @@ class TestMisc(unittest.TestCase):
"""Avro should raise an AvroTypeException when attempting to write a decimal with a larger exponent than the schema's scale."""
datum = decimal.Decimal("3.1415")
_, _, exp = datum.as_tuple()
- scale = -1 * exp - 1
+ scale = -1 * int(exp) - 1
schema = avro.schema.parse(
json.dumps(
{
@@ -521,7 +521,7 @@ class TestMisc(unittest.TestCase):
"""Avro should raise an AvroTypeException when attempting to write a decimal with a larger exponent than the schema's scale."""
datum = decimal.Decimal("3.1415")
_, _, exp = datum.as_tuple()
- scale = -1 * exp - 1
+ scale = -1 * int(exp) - 1
schema = avro.schema.parse(
json.dumps(
{