Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

datetime.strptime no longer raisesValueError: stray % in format '%Y %' #131434

Closed
Assignees
serhiy-storchaka
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@westandskif

Description

@westandskif

Bug report

Bug description:

in 3.13.2 and 3.13.1datetime.strptime no longer raisesValueError: stray % in format '%Y %'

Python 3.13.2 (main, Mar 19 2025, 01:28:14) [Clang 16.0.0 (clang-1600.0.26.6)] on Darwin>>> from datetime import datetime>>> datetime.strptime("2000 %", "%Y %")datetime.datetime(2000, 1, 1, 0, 0)

as it used to do in 3.13.0:

Python 3.13.0 (main, Mar 19 2025, 01:42:48) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin>>> from datetime import datetime>>> datetime.strptime("2000 %", "%Y %")Traceback (most recent call last):  File "<python-input-1>", line 1, in <module>    datetime.strptime("2000 %", "%Y %")    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^  File "/Users/nik/.pyenv/versions/3.13.0/lib/python3.13/_strptime.py", line 573, in _strptime_datetime    tt, fraction, gmtoff_fraction = _strptime(data_string, format)                                    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^  File "/Users/nik/.pyenv/versions/3.13.0/lib/python3.13/_strptime.py", line 348, in _strptime    raise ValueError("stray %% in format '%s'" % format) from NoneValueError: stray % in format '%Y %'

and e.g. 3.10:

Python 3.10.15 (main, Nov 28 2024, 23:39:17) [Clang 16.0.0 (clang-1600.0.26.4)] on Darwin>>> from datetime import datetime>>> datetime.strptime("2000 %", "%Y %")Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/Users/nik/.pyenv/versions/3.10.15/lib/python3.10/_strptime.py", line 568, in _strptime_datetime    tt, fraction, gmtoff_fraction = _strptime(data_string, format)  File "/Users/nik/.pyenv/versions/3.10.15/lib/python3.10/_strptime.py", line 345, in _strptime    raise ValueError("stray %% in format '%s'" % format) from NoneValueError: stray % in format '%Y %'

edit 1:
got the same in the latest 3.12.9 (used to work in older 3.12)

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Labels

stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp