python / python/cpython

Non-package module loaded from ModInfo object retains __path__ from previously loaded package.

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

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

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

Assume you have two separate modules with the same name. One is a package, one is not.

Use pkgutil.itermodules to get a ModuleInfo object for the package, then load the it using find_module and load_module. This object has a __path__ object with the location of package, as expected.

Next, do the same for the non-package module. The resulting module object should have no __path__ attribute, but instead it has one with the location of the package opened previously.

This can be replicated with a structure such as \module\submodule\submodule.py, using \module and \module\submodule as the arguments for the two calls to pkgutil.itermodules.

Your environment

  • CPython versions tested on: 3.10.7, 3.11.0rc2
  • Operating system and architecture: Windows 10

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

Tái hiện hành vi với hai bố cục module được mô tả trong issue, sử dụng pkgutil.itermodules, sau đó là find_module và load_module. So sánh các đối tượng module package và non-package; được xem là hoàn tất khi module non-package không còn giữ path từ package đã được tải trước đó.

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
backend
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.