Skip to content

Commit

Permalink
raise an exception on NaN and Infinity decimal values
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Oct 15, 2012
1 parent 04cf4d3 commit b2f6758
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion boto/dynamodb/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def serialize_num(s):
validation to ensure no loss of precision.
"""
try:
return str(dynamodb_context.create_decimal(s))
n = str(dynamodb_context.create_decimal(s))
if filter(lambda x: x in n, ('Infinity', 'NaN')):
raise TypeError('Infinity and NaN not supported')
return n
except Exception, e:
msg = '{0} numeric for `{1}`\n{2}'.format(\
e.__class__.__name__, s, e.message or '')
Expand Down

0 comments on commit b2f6758

Please sign in to comment.