OSError: [Errno 22] Invalid argument when serving files with last modified time before 1969-12-31 12:00 UTC on windows
還沒有人認領這個 Issue。
- 主要語言
- 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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Lib/http/server.py 中的 http.server.SimpleHTTPRequestHandler.send_head() 開始,尤其檢查所引用的 gmtime() 呼叫周圍的檔案時間戳處理。在 Windows 上使用 mtime 早於 1969-12-31 的檔案重現該行為,然後檢視連結的 PR gh-101036。完成標準是提供此類檔案時不再引發 OSError: [Errno 22]。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- web-dev
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100