python / python/cpython

`datetime.strptime` accepts incompatible arguments

オープン
#124,549 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

If you over-specify a datetime strptime string, it seems that datetime.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 get different 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
  • gh-125009
  • gh-132524

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

datetime.strptime の実装から着手し、関連する PR gh-125009 と gh-132524 を調査して、現在の方向性と関連テストを確認する。競合する重複フィールドについて、エラーにするのか、警告を出すのか、それとも引き続き受け入れるのかを決定する。完了の条件は、動作とテストが決定された方針を反映していることである。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。