Skip to content

Conversation

@fbochu
Copy link

@fbochu fbochu commented Jan 19, 2015

Timedelta serialisation does not work on Python 2.6.

timedelta.total_seconds() is only supported since Python 2.7 (https://docs.python.org/2.7/library/datetime.html#datetime.timedelta.total_seconds), so we need a fallback for python 2.6.

Copy link
Contributor

Choose a reason for hiding this comment

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

We isolate any version branching code into compat.py.
Have a function named total_seconds(timedelta) that provides this in compat.py and then call that from here.
Otherwise seems fine.

@lovelydinosaur lovelydinosaur added this to the 3.0.4 Release milestone Jan 19, 2015
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we actually need this - the only division we've added will always be float on both 2 and 3, since we're dividing by a float.

lovelydinosaur added a commit that referenced this pull request Jan 19, 2015
…liser-python26-support

Fix timedelta JSON serialization on Python 2.6.
@lovelydinosaur lovelydinosaur merged commit b3a0a27 into encode:master Jan 19, 2015
@lovelydinosaur
Copy link
Contributor

Nice work, thanks!

@fbochu fbochu deleted the fbochu/timedelta-json-serialiser-python26-support branch January 19, 2015 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants