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 accepts incompatible arguments #124549

Open
Labels
extension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@pganssle

Description

@pganssle

Bug report

Bug description:

If you over-specify a datetime strptime string, it seems thatdatetime.strptime when encountering a component that has been specified twice, will overwrite earlier values with more recent ones.

>>>datetime.strptime("200099","%Y%y")datetime.datetime(1999,1,1,0,0)

One approach would be to ban over-specified formats, but that would be a problem for someone who wants to, use a format like "%M %B" (e.g. something sortable by month number while also showing month name), so I think we don't want to do that.

Alternatively we could start raising an exception if you getdifferent values from these two things, or possibly a warning.

Or we can just accept that if you use a weird format you should expect weird behavior.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp