-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-70647: Better promote how to safely parse yearless dates in datetime. #116179
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
Conversation
…datetime. Every four years people encounter this because it just isn't obvious. This moves the footnote up to a note with a code example. We'd love to change the default year value for datetime but doing that could have other consequences for existing code. This documented workaround *always* works.
|
Perhaps this should be only merged to the backport branches, not main. |
|
@gpshead Looks like this may need some tidying up if you are still interested. |
|
This has already been partially implemented (the smaller note) do we still want to add the larger note since its deprecated anyway? |
|
Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…datetime. (pythonGH-116179) * pythongh-70647: Better promote how to safely parse yearless dates in datetime. Every four years people encounter this because it just isn't obvious. This moves the footnote up to a note with a code example. We'd love to change the default year value for datetime but doing that could have other consequences for existing code. This documented workaround *always* works. * doctest code within note is bad, dedent. * Update to match the error message. * remove no longer referenced footnote * ignore the warning in the doctest * use Petr's suggestion for the docs to hide the warning processing * cover date.strptime (3.14) as well (cherry picked from commit b8d3fddba6e96e693ced0d3b8f6ddbd61428fd32) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
|
GH-143037 is a backport of this pull request to the 3.14 branch. |
|
I realize we may simplify the text around this when we actually do the deprecation behavior change (which we could choose to do now that we're 3.15 though it's nicer to wait longer). But having the detail in the docs and the backport to the stable docs still seems good so I fixed this up. a backport to 3.13 docs will need to be manual due to the added method in 3.14. |
… datetime. (GH-116179) (#143037) gh-70647: Better promote how to safely parse yearless dates in datetime. (GH-116179) * gh-70647: Better promote how to safely parse yearless dates in datetime. Every four years people encounter this because it just isn't obvious. This moves the footnote up to a note with a code example. We'd love to change the default year value for datetime but doing that could have other consequences for existing code. This documented workaround *always* works. * doctest code within note is bad, dedent. * Update to match the error message. * remove no longer referenced footnote * ignore the warning in the doctest * use Petr's suggestion for the docs to hide the warning processing * cover date.strptime (3.14) as well (cherry picked from commit b8d3fdd) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
…datetime. (pythonGH-116179) * pythongh-70647: Better promote how to safely parse yearless dates in datetime. Every four years people encounter this because it just isn't obvious. This moves the footnote up to a note with a code example. We'd love to change the default year value for datetime but doing that could have other consequences for existing code. This documented workaround *always* works. * doctest code within note is bad, dedent. * Update to match the error message. * remove no longer referenced footnote * ignore the warning in the doctest * use Petr's suggestion for the docs to hide the warning processing * cover date.strptime (3.14) as well
|
GH-143038 is a backport of this pull request to the 3.13 branch. |
… datetime. (GH-116179) (#143038) * gh-70647: Better promote how to safely parse yearless dates in datetime. (GH-116179) * gh-70647: Better promote how to safely parse yearless dates in datetime. Every four years people encounter this because it just isn't obvious. This moves the footnote up to a note with a code example. We'd love to change the default year value for datetime but doing that could have other consequences for existing code. This documented workaround *always* works. * doctest code within note is bad, dedent. * Update to match the error message. * remove no longer referenced footnote * ignore the warning in the doctest * use Petr's suggestion for the docs to hide the warning processing * cover date.strptime (3.14) as well * remove date.strptime mentions from 3.14
Every four years people encounter this in part because it just isn't obvious that partial incomplete date parsing is not what
datetime.strptimeis designed for. This moves the footnote up to a more explanatory inline note with a code example.We'd love the default year value for datetime to be different, but changing that could have other consequences for existing code. This documented workaround always works.
📚 Documentation preview 📚: https://cpython-previews--116179.org.readthedocs.build/