Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't automatically unpack datetime objects in the message spec #4497

Merged
merged 6 commits into from Nov 10, 2013

Conversation

minrk
Copy link
Member

@minrk minrk commented Nov 6, 2013

I'm relying a bit on the IPython.parallel test coverage, so we'll see how this goes.
If anything is broken after this, at least we know where we need to add tests.

protects user-defined strings from being deserialized to datetime objects
datetime objects are no longer automatically deserialized outside of headers.
@Carreau
Copy link
Member

Carreau commented Nov 6, 2013

looks good.
Speeking of test, you want to add some already ?

@minrk
Copy link
Member Author

minrk commented Nov 6, 2013

Yes, I'll add some specifically for the changed behavior

@@ -675,7 +675,7 @@ def _extract_metadata(self, msg):
if 'date' in parent:
md['submitted'] = parent['date']
if 'started' in msg_meta:
md['started'] = msg_meta['started']
md['started'] = extract_dates(msg_meta['started'])
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to separate out the function for turning a single iso8601 string into a datetime, so that it's clearer where we're handling a single value as opposed to a container?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could, though almost everywhere there might be a datetime the value could also be None, and extract_dates handles that logic.

Copy link
Member

Choose a reason for hiding this comment

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

I'd still be inclined to split that bit out - extract_dates could simply call the new function on anything that's not a list or a dict.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, will do.

header and parent_header date time objects are automatically parsed.
metadata and content are not, but at least they are automatically serialized.
@minrk
Copy link
Member Author

minrk commented Nov 6, 2013

added parse_date for single-object parsing, and a few more tests of datetime handling for jsonutil and Session.

@takluyver
Copy link
Member

👍

@Carreau
Copy link
Member

Carreau commented Nov 10, 2013

Merging from my phone (at least trying)

Carreau added a commit that referenced this pull request Nov 10, 2013
don't automatically unpack datetime objects in the message spec

only unpack in headers
move handling of datetime objects in content and metadata to application-level code
minor fix to ISO8601 re (closes #4493)
@Carreau Carreau merged commit c1cf1a9 into ipython:master Nov 10, 2013
@minrk minrk deleted the datetime-session branch March 31, 2014 23:36
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
don't automatically unpack datetime objects in the message spec

only unpack in headers
move handling of datetime objects in content and metadata to application-level code
minor fix to ISO8601 re (closes ipython#4493)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qtconsole cannot print an ISO8601 date at nanosecond precision
3 participants