-
Notifications
You must be signed in to change notification settings - Fork 30
bug: Serialize Decimal correctly for ios aps #900
Conversation
Codecov Report
@@ Coverage Diff @@
## master #900 +/- ##
=======================================
Coverage 100% 100%
=======================================
Files 56 56
Lines 9709 10088 +379
=======================================
+ Hits 9709 10088 +379
Continue to review full report at Codecov.
|
autopush/router/apns2.py
Outdated
class ComplexEncoder(json.JSONEncoder): | ||
def default(self, obj): | ||
if isinstance(obj, Decimal): | ||
return int(float(obj.to_integral())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use to_integral_value? The docs indicate it should already return an int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, this is why reading a code review comment while following a keynote is probably not a good idea. Misread your comment. sigh
autopush/router/apns2.py
Outdated
class ComplexEncoder(json.JSONEncoder): | ||
def default(self, obj): | ||
if isinstance(obj, Decimal): | ||
return int(float(obj.to_integral_value())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should kill the float() here: to_integral_value already clips it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks!
closes #899