Time-only parsing during a repeated DST hour raises uncaught AmbiguousTimeError
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
まず dateparser/parser.py の _correct_for_time_frame を読み、特に tz.utcoffset() の呼び出しと例外処理を確認してください。提供されたスクリプトで、繰り返される時刻 1:30am のケースを使って問題を再現し、前後の時刻と比較してください。パーサーがタイムゾーンのポリシーに従うか、AmbiguousTimeError を漏らさずに None を返せば完了です。このケースに絞ったテストを追加するか、実行してください。
索引モデルが issue の本文から書いたものです。
説明
Hullo folks,
I'm doing some research for Tessl Code Review and we ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:
Parsing a time during the repeated daylight-saving hour raises pytz.AmbiguousTimeError out of dateparser.parse() when using an aware RELATIVE_BASE and PREFER_DATES_FROM="past".
The ambiguity is real, but an ordinary time string currently escapes the parser's handling as an uncaught exception, unlike adjacent times.
from datetime import datetime
import dateparser
import pytz
settings = {
"TIMEZONE": "America/Los_Angeles",
"PREFER_DATES_FROM": "past",
"RELATIVE_BASE": pytz.timezone("America/Los_Angeles").localize(
datetime(2020, 11, 1, 12)
),
}
for time in ("0:30am", "1:30am", "2:30am"):
try:
print(time, dateparser.parse(time, settings=settings))
except Exception as error:
print(time, type(error).__name__, str(error))
Actual output:
0:30am 2020-11-01 00:30:00
1:30am AmbiguousTimeError 2020-11-01 01:30:00
2:30am 2020-11-01 02:30:00
Expected: handle the repeated hour according to the parser's timezone policy, or return None if it cannot be resolved, rather than leaking this exception.
The offset lookup in _correct_for_time_frame calls tz.utcoffset() with a naive wall time and catches UnknownTimeZoneError and NonExistentTimeError, but not AmbiguousTimeError. This is a different failure from the aware-datetime ValueError handled by #1362.
I ran this focused reproduction against current source ce8c4390dad4629daa2f154e7303052f9d88daec on macOS, Python 3.14.2, pytz 2026.6. No production data or full test suite was used; no patch is included.
Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.
We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.
Baptiste
- 主要言語
- Python
- スター
- 2.9k
- フォーク
- 545
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 17
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
scrapinghub/dateparser のほかの issue
-
StaticTzInfo has localize() but not normalize(), so pytz-detecting code crashes on it再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 70/100
scrapinghub/dateparser#1591 ·
メンテナーはふだん 1 日以内に返信
-
Validate on Python 3.15対応中かも @kishan3 が 25 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
scrapinghub/dateparser#1548 ·
メンテナーはふだん 1 日以内に返信
-
search_dates() raises IndexError for the zh-Hans, zh-Hant and yue locales対応中かも @abhi-0203 が 88 日前に担当しました。 オープンsearch_dates Status: Bug confirmed Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
scrapinghub/dateparser#1372 ·
メンテナーはふだん 1 日以内に返信
-
Adopt sphinx-scrapy, with docs dependencies in a dependency group対応中かも @yamilmaud が 3 日前に担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 25/100
scrapinghub/dateparser#1613 ·
メンテナーはふだん 1 日以内に返信
-
Enable branch coverage, upload test results and use Codecov OIDC対応中かも @yamilmaud が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 20/100
scrapinghub/dateparser#1611 ·
メンテナーはふだん 1 日以内に返信
scrapinghub/dateparser の issue をすべて見る
似ている issue
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
MakazhanAlpamys/Soup#3589 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/clickhouse-connect#1266 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
biosustain/growthcurves_app#89 ·
メンテナーはふだん 1 日以内に返信
-
`LogProxyConsumer._on_relation_departed` raises `APIError` when the promtail service does not existオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
canonical/loki-k8s-operator#695 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信