Title: `datetime.strptime(dt.strftime("%c"), "%c"))` fails when year is <1000. · Issue #124529 · python/cpython · GitHub
Open Graph Title: `datetime.strptime(dt.strftime("%c"), "%c"))` fails when year is <1000. · Issue #124529 · python/cpython
X Title: `datetime.strptime(dt.strftime("%c"), "%c"))` fails when year is <1000. · Issue #124529 · python/cpython
Description: Bug report Bug description: >>> from datetime import datetime >>> datetime.strptime(datetime(1000, 1, 1).strftime("%c"), "%c") datetime.datetime(1000, 1, 1, 0, 0) >>> datetime.strptime(datetime(999, 1, 1).strftime("%c"), "%c") Traceback ...
Open Graph Description: Bug report Bug description: >>> from datetime import datetime >>> datetime.strptime(datetime(1000, 1, 1).strftime("%c"), "%c") datetime.datetime(1000, 1, 1, 0, 0) >>> datetime.strptime(datetime(999...
X Description: Bug report Bug description: >>> from datetime import datetime >>> datetime.strptime(datetime(1000, 1, 1).strftime("%c"), "%c") datetime.datetime(1000, 1, 1, 0,...
Opengraph URL: https://github.com/python/cpython/issues/124529
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`datetime.strptime(dt.strftime(\"%c\"), \"%c\"))` fails when year is \u003c1000.","articleBody":"# Bug report\n\n### Bug description:\n\n```python\n>>> from datetime import datetime\n>>> datetime.strptime(datetime(1000, 1, 1).strftime(\"%c\"), \"%c\")\ndatetime.datetime(1000, 1, 1, 0, 0)\n>>> datetime.strptime(datetime(999, 1, 1).strftime(\"%c\"), \"%c\")\nTraceback (most recent call last):\n File \"\u003cpython-input-1>\", line 1, in \u003cmodule>\n datetime.strptime(datetime(999, 1, 1).strftime(\"%c\"), \"%c\")\n ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/nlx5/Documents/Programming/Python/cpython/Lib/_strptime.py\", line 573, in _strptime_datetime\n tt, fraction, gmtoff_fraction = _strptime(data_string, format)\n ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^\n File \"/home/nlx5/Documents/Programming/Python/cpython/Lib/_strptime.py\", line 352, in _strptime\n raise ValueError(\"time data %r does not match format %r\" %\n (data_string, format))\nValueError: time data 'Tue Jan 1 00:00:00 999' does not match format '%c'\n```\n\nDiscovered this when adding some hypothesis tests for `strptime`/`strftime`. I doubt this is a real problem anyone is going to have in the real world, but maybe.\n\nI do not know if this is locale-specific or OS specific.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-124778\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pganssle","@type":"Person","name":"pganssle"},"datePublished":"2024-09-25T17:59:36Z","url":"https://github.com/python/cpython/issues/124529"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:06d4a7b5-c82c-3463-c0eb-b10c2255eec3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBCE:296654:36111B4:4802FBB:6B020974 |
| html-safe-nonce | c95787ff1e5a2ebbe0108a9ed18713480ca082bb3fa61a16911eab60d1bc695e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkNFOjI5NjY1NDozNjExMUI0OjQ4MDJGQkI6NkIwMjA5NzQiLCJ2aXNpdG9yX2lkIjoiNTQ0ODc5NDA4MjcyMzg5MTU3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4d36dca71cfe96e1174ff7ec77e490496c5765a2f08a87f46b33139e58627e58 |
| hovercard-subject-tag | issue:2548650466 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/124529/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23826a01edc3b0d4a4ebdd268aea8845257f90ab05351a22b1a847c5c55a40ac/python/cpython/issues/124529 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23826a01edc3b0d4a4ebdd268aea8845257f90ab05351a22b1a847c5c55a40ac/python/cpython/issues/124529 |
| og:image:alt | Bug report Bug description: >>> from datetime import datetime >>> datetime.strptime(datetime(1000, 1, 1).strftime("%c"), "%c") datetime.datetime(1000, 1, 1, 0, 0) >>> datetime.strptime(datetime(999... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pganssle |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width