GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-80010: Expand fromisoformat to include most of ISO-8601 by pganssle · Pull Request #92177 · python/cpython

Conversation

@pganssle

@pganssle pganssle commented May 2, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This should cover all of ISO-8601 except for fractional non-second components.

@godlygeek Would you mind taking a look?

Note: Currently the tests are mostly written as hypothesis tests using the stubs from #22863. Before merge we can try to refactor those out into a big matrix of examples, but for now it's useful to know that we have good coverage of the enormous state space here.

#80010

To Do:

  • Add news entry
  • Update docstrings
  • What's new entry

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

godlygeek and petsuter reacted with thumbs up emoji r-bird and petsuter reacted with heart emoji serhiy-storchaka, geryogam, layday, and petsuter reacted with rocket emoji
All reactions
  • 👍 2 reactions
  • ❤️ 2 reactions
  • 🚀 4 reactions
@pganssle
pganssle requested a review from abalkin as a code owner May 2, 2022 18:53
@ghost

ghost commented May 2, 2022 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added the awaiting core review label May 2, 2022
@pganssle
pganssle force-pushed the expand_fromisoformat branch from 55ee790 to c79e33f Compare May 2, 2022 23:12
@pganssle

pganssle commented May 2, 2022

Copy link
Copy Markdown
Member Author

I've added an explicit test matrix that doesn't rely on the hypothesis stubs. Feel free to ignore them as part of the review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JelleZijlstra
JelleZijlstra reviewed May 2, 2022
View reviewed changes

@JelleZijlstra JelleZijlstra left a comment

Copy link
Copy Markdown
Member

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.

A few comments, I'll have to study the C code more closely.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/datetime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/datetime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/datetime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/datetime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/datetimetester.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread isoformatter.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
serhiy-storchaka self-requested a review May 3, 2022 07:03
@orent

orent commented May 3, 2022

Copy link
Copy Markdown

Is there a way to limit this to only the rfc3339 subset? The full set of iso8601 features is not always appropriate.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pganssle

pganssle commented May 3, 2022

Copy link
Copy Markdown
Member Author

Is there a way to limit this to only the rfc3339 subset? The full set of iso8601 features is not always appropriate.

This sort of thing is the reason we delayed this expansion — the scope can easily grow if we do not constrain it to be something very specific, and we couldn't come up with a good way to allow users to express their preferences about what would be parsed. The approach we settled on is that fromisoformat would have a broad scope and not be configurable, and we will leave it to another library (or possibly another function) to allow further configuration.

I don't think it would be completely absurd to have a .fromrfc or fromrfc3339 method, though also RFC 3339 is so much more constrained than ISO 8601 that it's much easier to parse with something like a regex.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pganssle
pganssle force-pushed the expand_fromisoformat branch 2 times, most recently from f83a340 to e51e734 Compare May 3, 2022 18:36
@pganssle pganssle mentioned this pull request May 3, 2022
Add datetime.UTC alias for datetime.timezone.utc #91928
Closed
@pganssle
pganssle requested review from a team, 1st1, Fidget-Spinner, asvetlov, berkerpeksag, gvanrossum, lysnikolaou, markshannon, methane, pablogsal and rhettinger as code owners May 3, 2022 22:31
@pganssle
pganssle force-pushed the expand_fromisoformat branch from 0b2bffd to ea9c3d6 Compare May 3, 2022 22:32
@gvanrossum
gvanrossum removed their request for review May 3, 2022 22:46
godlygeek
godlygeek reviewed May 4, 2022
View reviewed changes
Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.11.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_datetimemodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/datetime.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

jerub
jerub reviewed May 4, 2022
View reviewed changes

@jerub jerub left a comment

Copy link
Copy Markdown

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.

Thanks for asking me to review this change. I've made a few minor notes.

Great to see that we're building these batteries included. It would also be good to have a really solid RFC3339 parser as well. ISO 8601 has the mindshare because of the name, but RFC 3339 is the quality standard that people actually want.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/datetime.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Fidget-Spinner
Fidget-Spinner removed their request for review May 4, 2022 08:33
@orent

orent commented May 4, 2022

Copy link
Copy Markdown

I don't think it would be completely absurd to have a .fromrfc or fromrfc3339 method, though also RFC 3339 is so much more constrained than ISO 8601 that it's much easier to parse with something like a regex.

Instead of adding yet another method - how about making the constructor accept a string? Many other builtin types have a constructor that accepts a single string argument and round-trips their __str__ (which may or may not be the same as their __repr__).

So my suggestion is for the constructor to accept the __str__ which is basically rfc3339 (possibly with a different separator) and the .fromisoformat() method would accept the larger set of ISO8601 values.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rhettinger
rhettinger removed their request for review May 5, 2022 04:14
pganssle added 19 commits May 5, 2022 11:03
@pganssle
Explicitly handle 0-length tzstr
3d0fb7a
@pganssle
Raise exceptions from None
cc8c737
@pganssle
Add test cases around week 53
31bf63e
@pganssle
Add examples around week 53
5bfb3fc
@pganssle
Update docstrings
4879a47
@pganssle
Add news entry
3cd657f
@pganssle
Add what's new entry
763d5bb
@pganssle
Be consistent about ISO 8601
3a06505
@pganssle
Change name of isoformat separator detection function
e643f02
@pganssle
Remove 'mode' logic and update comments
5046809
@pganssle
Fix segfault case
90093bf
@pganssle
Explicitly cast signed to unsigned
6fc8157
@pganssle
Document that ordinal dates are not supported
d9a766b
@pganssle
Remove dead code
04ed787
@pganssle
Various fixes
6da3e90
@pganssle
Fix example
92cc0be
@pganssle
Add example for time.fromisoformat
bec0bee
@pganssle
Fix trailing colon
aad6011
@pganssle
Remove fromisoformat property test
a33d776
@pganssle
pganssle force-pushed the expand_fromisoformat branch from 8cbe22e to a33d776 Compare May 5, 2022 17:04
@pganssle

pganssle commented May 6, 2022

Copy link
Copy Markdown
Member Author

Ok, I think we're down to just nits and other things that can easily be taken care of after feature freeze. I'm going to merge this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pganssle
pganssle merged commit 1303f8c into python:main May 6, 2022
@bedevere-bot bedevere-bot removed the awaiting core review label May 6, 2022
@cretz cretz mentioned this pull request Oct 31, 2022
Feature/datetime conversions temporalio/sdk-python#174
Closed
@mikelei8291 mikelei8291 mentioned this pull request Apr 4, 2023
Fix mismatching parameter in code example of time.fromisoformat() #103246
Closed
@arpad-m arpad-m mentioned this pull request Oct 18, 2023
Add endpoint for querying time info for lsn neondatabase/neon#5497
Merged
5 tasks
@ajarr ajarr mentioned this pull request Feb 18, 2026
mgr/rbd_support: Fix "start-time" arg behavior ceph/ceph#66735
Merged
4 of 14 tasks
This was referenced Aug 6, 2026
feat(examples): escape CrewAI 1.15 unified memory to OKF (#1609) moorcheh-ai/memanto#1821
Closed
feat(postgres): add Restic remote backups and restore validation Lebowski89/homelab#563
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Aug 15, 2026
DSOM-Governed Diátaxis Documentation Pipeline & Config Standardisation linuxmalaysia/ASIMP#68
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra left review comments
@abalkin abalkin Awaiting requested review from abalkin
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@pablogsal pablogsal Awaiting requested review from pablogsal
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou
@markshannon markshannon Awaiting requested review from markshannon
@methane methane Awaiting requested review from methane
@1st1 1st1 Awaiting requested review from 1st1
@asvetlov asvetlov Awaiting requested review from asvetlov
@isidentical isidentical Awaiting requested review from isidentical
@tiran tiran Awaiting requested review from tiran
@iritkatriel iritkatriel Awaiting requested review from iritkatriel
+2 more reviewers
@godlygeek godlygeek godlygeek left review comments
@jerub jerub jerub left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@pganssle @orent @godlygeek @jerub @JelleZijlstra @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.