Closed
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")
""
I would have expected:
>>> from datetime import datetime
>>> datetime(2024, 9, 25).strftime("\x00%Y-%m-%d")
"\x002024-09-25"
Discovered 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.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done