python / python/cpython

OSError: [Errno 22] Invalid argument when serving files with last modified time before 1969-12-31 12:00 UTC on windows

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

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

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

説明

Bug report

http.server.SimpleHTTPRequestHandler.send_head() does not check if a file's mtime is valid for gmtime() on windows.
An OSError: [Errno 22] Invalid argument exception will be raised which is normal according to the documentation.

https://github.com/python/cpython/blob/ef633e5000222a3dba74473c49d6a81fca0a44ec/Lib/http/server.py#L752
https://github.com/python/cpython/blob/ef633e5000222a3dba74473c49d6a81fca0a44ec/Lib/http/server.py#L766

I encounter this error when using windows built-in unzip functionality to unzip a windows WireGuard client exported zip file.
The zip file does not contain any timestamp information. And windows will not auto fill timestamp information when unzipping.
And win32 api GetFileInformationByHandle will report back a timestamp of -11635213907.559603

Your environment

  • CPython versions tested on: 3.10.9, 3.11.1, 3.12.0a4+
  • Operating system and architecture: windows 11 pro 22h2 OS build 22621.1105 amd64
Linked PRs
  • gh-101036

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

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

はじめの一歩

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

調査の方向性

Lib/http/server.py の http.server.SimpleHTTPRequestHandler.send_head() から始め、特に参照されている gmtime() 呼び出し周辺のファイルタイムスタンプ処理を確認してください。1969-12-31 より前の mtime を持つファイルを使って Windows 上で動作を再現し、その後、リンクされている PR gh-101036 を確認してください。そのようなファイルを提供しても OSError: [Errno 22] が発生しなくなれば完了です。

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

評価

技術スタック
python
領域
web-dev
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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