profiling: --collapsed export fails with UnicodeEncodeError on non-ASCII frame names
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
CollapsedStackCollector.export (Lib/profiling/sampling/stack_collector.py) opens its output with open(filename, "w") — no encoding=. It is the only exporter in that module missing it; FlamegraphCollector.export, the JSONL exporter and the heatmap exporter all pass encoding="utf-8". Because the collapsed format writes frame names verbatim (the JSON exporters escape non-ASCII via ensure_ascii), --collapsed export raises UnicodeEncodeError when a sampled frame's function or file name contains non-ASCII characters under a non-UTF-8 locale, or surrogate-escaped characters (from an undecodable path) on any locale:
UnicodeEncodeError: 'ascii' codec can't encode characters ...
UnicodeEncodeError: 'utf-8' codec can't encode character '\udc80' ... surrogates not allowed
Non-English identifiers are common and non-UTF-8 locales are supported, so profiling such a program with --collapsed produces no output and an uncaught error.
CPython versions tested on:
CPython main
Operating systems tested on:
Linux, macOS
Linked PRs
- gh-156811
- gh-156814
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/profiling/sampling/stack_collector.py から始め、CollapsedStackCollector.export を UTF-8 出力を指定している他の exporter と比較してください。まずリンクされている PR gh-156811 と gh-156814 を確認してください。完了の条件は、UnicodeEncodeError を発生させずに、非 ASCII のフレーム名と surrogate-escaped のフレーム名に対する collapsed export が成功することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- performance
- issue の種類
- バグ
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100