python / python/cpython

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

Đang mở
#99,954 7 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

OS-windows type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện hành vi được báo cáo trên Windows x64 với Python 3.10.4: mở một tệp có đường dẫn dài hơn 248 ký tự, sau đó thử import một module từ một đường dẫn quá dài được thêm vào sys.path. Truy vết các lỗi mở và import để xác định điều kiện về độ dài bị mất ở đâu. Được xem là hoàn tất khi cả hai trường hợp đều báo lỗi chính xác về độ dài đường dẫn thay vì FileNotFoundError hoặc ModuleNotFoundError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.