Skip to content
Browse files

raise an exception on NaN and Infinity decimal values

  • Loading branch information...
1 parent 04cf4d3 commit b2f67588d9d55b0e1956fb39532af6f383349f38 @disruptek committed Oct 14, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 boto/dynamodb/types.py
View
5 boto/dynamodb/types.py
@@ -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 '')

0 comments on commit b2f6758

Please sign in to comment.
Something went wrong with that request. Please try again.