profiling.sampling reports third-party modules as stdlib when site-packages is inside the stdlib directory
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Đọc Lib/profiling/sampling/module_utils.py, đặc biệt là extract_module_name() và thông tin đường dẫn từ get_python_path_info(). Tái hiện trường hợp được báo cáo bằng sysconfig.get_path('purelib') và đoạn mã được cung cấp, sau đó kiểm tra các bài kiểm thử profiling sampling hiện có. Công việc hoàn tất khi thư mục khớp cụ thể nhất được ưu tiên, thư viện chuẩn được ưu tiên khi hòa và ví dụ phân loại requests.api là site-packages mà không phân loại sai các tệp thư viện chuẩn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
Bug description:
profiling.sampling.module_utils.extract_module_name() checks the stdlib directory before the site-packages directories. In a regular (non-venv) installation site-packages is a subdirectory of the stdlib directory (Lib\site-packages on Windows, lib/pythonX.Y/site-packages for python.org, pyenv, conda or Docker builds, and Lib/site-packages in a source build), so every file installed there matches the stdlib check first.
import os
import sysconfig
from profiling.sampling.module_utils import extract_module_name, get_python_path_info
path_info = get_python_path_info()
filename = os.path.join(sysconfig.get_path('purelib'), 'requests', 'api.py')
print(extract_module_name(filename, path_info))
Output (Windows, <prefix>\Lib is the stdlib directory and <prefix>\Lib\site-packages is the site-packages directory):
('site-packages.requests.api', 'stdlib')
Expected:
('requests.api', 'site-packages')
As a result, the heatmap index lists third-party code under "Standard Library", inside a folder named site-packages, instead of under "Site Packages", and the flamegraph labels of such frames look like get (site-packages.requests.api:10). Doc/library/profiling.sampling.rst describes the heatmap index as organized by type (stdlib, site-packages, project). Only virtual environments (and the user site directory), where site-packages is not inside the stdlib directory, are classified correctly.
Simply checking site-packages first is not enough: on Windows site.getsitepackages() also returns sys.prefix, which is a parent of the stdlib directory and would then capture the stdlib files. The most specific (longest) matching directory should win, with stdlib winning a tie.
CPython versions tested on:
CPython main branch
(Lib/profiling/sampling/module_utils.py is identical on the 3.15 branch.)
Operating systems tested on:
Windows
Linked PRs
- gh-158993
- Ngôn ngữ chính
- Python
- Star
- 77.6k
- Fork
- 37.6k
- Merge trung bình
- 1 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 593
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
python/cpython#159061 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
3.14 3.15 3.16 stdlib type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python/cpython#159044 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A minor problem with the section "6.10.2. Membership test operations" from the language reference.Đang mởdocs pending
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
python/cpython#159034 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs: socket.htons() and friends raise ValueError for negative input since 3.14Có thể đã có người làm @vetrovk đã nhận 1 ngày trước. Đang mởdocs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
python/cpython#159012 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python/cpython
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
topoteretes/cognee#5647 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Sendspin/sendspin-python-cli#291 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
awslabs/visual-asset-management-system#414 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/python-sdk#3670 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aicell-lab/bioengine#232 ·
Maintainer thường phản hồi trong vòng 1 ngày