Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

bug: Serialize Decimal correctly for ios aps #900

Merged
merged 1 commit into from
May 21, 2017
Merged

bug: Serialize Decimal correctly for ios aps #900

merged 1 commit into from
May 21, 2017

Conversation

jrconlin
Copy link
Member

closes #899

@codecov-io
Copy link

codecov-io commented May 20, 2017

Codecov Report

Merging #900 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #900    +/-   ##
=======================================
  Coverage     100%    100%            
=======================================
  Files          56      56            
  Lines        9709   10088   +379     
=======================================
+ Hits         9709   10088   +379
Impacted Files Coverage Δ
autopush/tests/test_router.py 100% <100%> (ø) ⬆️
autopush/router/apns2.py 100% <100%> (ø) ⬆️
autopush/web/message.py 100% <0%> (ø) ⬆️
autopush/tests/test_endpoint.py 100% <0%> (ø) ⬆️
autopush/http.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9fa162...1580e21. Read the comment docs.

class ComplexEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Decimal):
return int(float(obj.to_integral()))
Copy link
Member

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.

Copy link
Member Author

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

class ComplexEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Decimal):
return int(float(obj.to_integral_value()))
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks!

@bbangert bbangert merged commit e6081e8 into master May 21, 2017
@bbangert bbangert deleted the bug/899 branch May 21, 2017 18:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialize Decimal values in iOS APNs output
4 participants