python / python/cpython

Open() on path that exceeds 248 char limit results in "FileNotFoundError: [Errno 2] No such file or directory"

未關閉
#99,954 7 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

OS-windows type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Attempting to open or appending paths to sys.path with paths that length exceed the 248 character limit results in incorrect errors. In the case of opening paths that exceeded the limit, rather than an error pointing to the path length being exceeded we see a file not found. A similar error handling issue is prevalent with appending paths that exceed the limit to sys.path. In this case when trying to access the module you will receive a module not found error. I am now aware the path limit can be disabled on installation or later but these false flags led me astray while debugging.

Reproduction Steps:

  • Create a text file whose path exceeds 248 characters
  • Attempt to read/write from that file
    or
  • Create a Python module whose path exceeds 248 characters
  • Attempt to import that module from an external directory by appending the path to sys.path

Environment

  • CPython versions tested on: 3.10.4
  • Operating system and architecture: Windows x64

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先在 Windows x64 與 Python 3.10.4 上重現回報的行為:開啟路徑超過 248 個字元的檔案,然後測試從附加至 sys.path 的過長路徑匯入模組。追蹤開啟與匯入失敗,以找出長度條件在哪個環節遺失。完成的標準是兩種情況都回報準確的路徑長度錯誤,而不是 FileNotFoundError 或 ModuleNotFoundError。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
operating-systems
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。