Title: `datetime.strftime` strings can be terminated by "\x00" literals · Issue #124531 · python/cpython · GitHub
Open Graph Title: `datetime.strftime` strings can be terminated by "\x00" literals · Issue #124531 · python/cpython
X Title: `datetime.strftime` strings can be terminated by "\x00" literals · Issue #124531 · python/cpython
Description: Bug report Bug description: Apparently the strftime parser treats \x00 as "end of string" in the format code, and the remainder of the string is ignored: >>> from datetime import datetime >>> datetime(2024, 9, 25).strftime("\x00%Y-%m-%d"...
Open Graph Description: Bug report Bug description: Apparently the strftime parser treats \x00 as "end of string" in the format code, and the remainder of the string is ignored: >>> from datetime import datetime >>> datet...
X Description: Bug report Bug description: Apparently the strftime parser treats \x00 as "end of string" in the format code, and the remainder of the string is ignored: >>> from datetime import...
Opengraph URL: https://github.com/python/cpython/issues/124531
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`datetime.strftime` strings can be terminated by \"\\x00\" literals","articleBody":"# Bug report\n\n### Bug description:\n\nApparently the `strftime` parser treats `\\x00` as \"end of string\" in the format code, and the remainder of the string is ignored:\n\n```python\n>>> from datetime import datetime\n>>> datetime(2024, 9, 25).strftime(\"\\x00%Y-%m-%d\")\n\"\"\n```\n\nI would have expected:\n\n```python\n>>> from datetime import datetime\n>>> datetime(2024, 9, 25).strftime(\"\\x00%Y-%m-%d\")\n\"\\x002024-09-25\"\n```\n\nDiscovered this when adding some hypothesis tests for `strptime`/`strftime`. I suspect again that if you include a null character in your datetime format string you should expect something to act weird as hell about it, but we should probably fix this anyway if it's not too costly.\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-125003\n* gh-125193\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/pganssle","@type":"Person","name":"pganssle"},"datePublished":"2024-09-25T18:38:02Z","url":"https://github.com/python/cpython/issues/124531"}
| 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:e2a0a0f6-6aff-0a48-0904-fb5de73c9d3c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7C8:148EE1:62EEE5:7CBD8C:6B020985 |
| html-safe-nonce | 179e3856c26dc49390457469733273eb2b0fe4059fd1f6d24a7b7b47ea29861e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0M4OjE0OEVFMTo2MkVFRTU6N0NCRDhDOjZCMDIwOTg1IiwidmlzaXRvcl9pZCI6IjgxNzM2NjUxNjUxNzExMDAwMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5c8ae89ff674e10ac5d7ff224f42026f881a955c3a48d04e97904c683f359313 |
| hovercard-subject-tag | issue:2548720837 |
| 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/124531/issue_layout |
| twitter:image | https://opengraph.githubassets.com/61c4e9222d361b8c35b70b43d7f888a866b657f5572f6b82b191b13564a00d97/python/cpython/issues/124531 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/61c4e9222d361b8c35b70b43d7f888a866b657f5572f6b82b191b13564a00d97/python/cpython/issues/124531 |
| og:image:alt | Bug report Bug description: Apparently the strftime parser treats \x00 as "end of string" in the format code, and the remainder of the string is ignored: >>> from datetime import datetime >>> datet... |
| 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