`.pyc` file in zipapp can be marked as stale if opened in a different timezone than the one it was created in
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
_get_mtime_and_size_of_source uses localtime rather than UTC --- in a zipapp, if the pyc was created in a timezone that is different than the timezone of the computer that it is being run on, it can be marked as 'stale', even though it shouldn't be --- for example, if the source file was last modified at 3:30 EST, that 3:30 EST will be stored in the pyc file as a Unix timestamp. However, if the zipapp is then transferred to a computer running PST, the modification time of the source file will be read from the zip file as 3:30 PST in unix time (through time.mktime), which will obviously be different than the 3:30 EST read from the pyc file directly (since it is never passed through time.mktime).
This seems to be because zip files do not store timezones with mtime, so Python is forced to interpret it as local time.
CPython versions tested on:
3.11, 3.13
Operating systems tested on:
Linux, macOS
Linked PRs
- gh-143868
- gh-143953
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 _get_mtime_and_size_of_source 開始,追蹤 zipapp 原始碼的 mtime 如何透過 time.mktime 轉換,以及它與 pyc 時間戳記的差異。在 Linux 或 macOS 上重現 Python 3.11 或 3.13 中所描述的時區差異,然後驗證在時區之間傳輸的 pyc 不會再被錯誤地標記為過期。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100