Skip to content

Commit cf41e80

Browse files
committed
normalized Type exception when casting Decimal type
PYTHON-468
1 parent eb449ec commit cf41e80

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cassandra/cqltypes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,10 @@ def serialize(dec, protocol_version):
369369
try:
370370
sign, digits, exponent = dec.as_tuple()
371371
except AttributeError:
372-
sign, digits, exponent = Decimal(dec).as_tuple()
372+
try:
373+
sign, digits, exponent = Decimal(dec).as_tuple()
374+
except Exception:
375+
raise TypeError("Invalid type for Decimal value: %r", dec)
373376
unscaled = int(''.join([str(digit) for digit in digits]))
374377
if sign:
375378
unscaled *= -1

0 commit comments

Comments
 (0)