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

Handle ISO formats with a trailing Z #12363

Merged
merged 1 commit into from Oct 17, 2023
Merged

Conversation

pfmoore
Copy link
Member

@pfmoore pfmoore commented Oct 17, 2023

No description provided.

Handles the format 2020-01-22T14:24:01Z (trailing Z)
which is not supported by older versions of fromisoformat.
"""
return datetime.datetime.fromisoformat(isodate.replace("Z", "+00:00"))
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this PR! Would it make sens to mention in the comment which Python version supports the Z suffix, so we know when we can drop this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure. I didn't have the time to go and check, but if you want to suggest a suitable wording, I'm fine with adding it.

The reason I left things vague is that I frankly found the various discussions around the deprecation of utcnow (here and on the cpython lists) rather confusing, and I don't feel confident enough to make any definitive statements 🙁

Copy link
Member

Choose a reason for hiding this comment

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

Ok, then I'm not going to be confident either :)

Copy link
Member Author

@pfmoore pfmoore Oct 17, 2023

Choose a reason for hiding this comment

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

Chicken! 🙂

Edit: Support for Z was added in 3.11 (I think!), but I don't know whether that's the only factor here...

@sbidoul sbidoul added this to the 23.3 milestone Oct 17, 2023
@pfmoore pfmoore closed this Oct 17, 2023
@pfmoore pfmoore reopened this Oct 17, 2023
@pfmoore
Copy link
Member Author

pfmoore commented Oct 17, 2023

Close and reopen because MacOS test failed and made a bunch of other tests skip...

@pfmoore
Copy link
Member Author

pfmoore commented Oct 17, 2023

Merging this on the basis that we can follow up with tests or improvements if needed.

@pfmoore pfmoore merged commit f3620cd into pypa:main Oct 17, 2023
33 of 50 checks passed
@pfmoore pfmoore deleted the safe_isoformat branch October 17, 2023 11:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2023
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.

None yet

2 participants