profiling.sampling reports third-party modules as stdlib when site-packages is inside the stdlib directory
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Lib/profiling/sampling/module_utils.pyを読み、特にextract_module_name()とget_python_path_info()のパス情報を確認してください。sysconfig.get_path('purelib')と提供されたスニペットを使って報告されたケースを再現し、既存のprofiling samplingテストを確認してください。最も具体的に一致するディレクトリが優先され、同点の場合は標準ライブラリが優先され、標準ライブラリのファイルを誤分類することなく、例でrequests.apiがsite-packagesに分類されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 77.6k
- フォーク
- 38.4k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 564
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
stdlib topic-XML type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Docs: problem with page "msvcrt — Useful routines from the MS VC runtime"再び着手できるかも @jikekei が 9 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンdocs
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
python/cpython#159072 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
Document unpacking in generator expressions (PEP 798)対応中かも @Marwan-verse が 6 日前に担当しました。 オープンdocs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
python/cpython#159061 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`http.client.HTTPSConnection._tunnel` raises `AttributeError: 'NoneType' object has no attribute 'encode'` when header value is `None`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン3.14 3.15 3.16 stdlib type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python/cpython#159044 · コメント 17 件 ·
メンテナーはふだん 1 日以内に返信
-
A minor problem with the section "6.10.2. Membership test operations" from the language reference.対応中かも @Rakshana0205 が 6 日前に担当しました。 オープンdocs pending
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
python/cpython#159034 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
Status: Triaged Type: Enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
canonical/craft-store#448 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
good first issue research size:s skill:numerics sub-issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SKaiNET-developers/SKaiNET#1372 ·
メンテナーはふだん 1 日以内に返信
-
debt
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/vscode-flake8#601 ·
メンテナーはふだん 1 日以内に返信