profiling: --collapsed export fails with UnicodeEncodeError on non-ASCII frame names
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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
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.
Hướng nghiên cứu
Bắt đầu với Lib/profiling/sampling/stack_collector.py và so sánh CollapsedStackCollector.export với các exporter khác có chỉ định đầu ra UTF-8. Trước tiên, hãy kiểm tra các PR được liên kết gh-156811 và gh-156814; được xem là hoàn thành khi collapsed export thành công đối với tên frame không phải ASCII và tên frame được escape bằng surrogate mà không có UnicodeEncodeError.
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
- performance
- Loại issue
- Lỗi
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 25/100