`profiling.sampling` in `--binary` mode raises a `UnicodeEncodeError` while collecting the samples
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start with Lib/profiling/sampling/binary_collector.py, where the traceback shows the failing write, and inspect how sample stack frame strings are encoded. Reproduce with the xarray documentation profiling command on Python 3.15.1; done means binary mode collects samples without raising UnicodeEncodeError for the reported surrogate character.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug report
when trying to profile building xarray's docs with profiling.sampling I get a UnicodeEncodeError while collecting the result.
For now, the command to reproduce is:
git clone https://github.com/pydata/xarray
cd xarray
pixi run -e doc python -m profiling.sampling run --binary -o profile.bin -m sphinx -b html -d _build/doctrees . _build/html
And the traceback is:
Traceback (most recent call last):
File "<frozen runpy>", line 201, in _run_module_as_main
File "<frozen runpy>", line 87, in _run_code
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/__main__.py", line 65, in <module>
main()
~~~~^^
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/cli.py", line 1011, in main
_main()
~~~~~^^
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/cli.py", line 1167, in _main
handler(args)
~~~~~~~^^^^^^
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/cli.py", line 1316, in _handle_run
collector = sample(
process.pid,
...<9 lines>...
blocking=args.blocking,
)
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/sample.py", line 535, in sample
profiler.sample(collector, duration_sec, async_aware=async_aware)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/sample.py", line 192, in sample
raise e from None
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/sample.py", line 180, in sample
collector.collect(stack_frames)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File ".../xarray/.pixi/envs/doc/lib/python3.15/profiling/sampling/binary_collector.py", line 112, in collect
self._writer.write_sample(stack_frames, timestamp_us)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'utf-8' codec can't encode character '\uddd0' in position 240: surrogates not allowed
I'm fully aware that this isn't a very minimal reproducer, but I didn't manage to find a minimal example as everything else I tried does not fail.
If you need more information or have any ideas on how to narrow this down I'd be happy to help.
versions:
python: 3.15.1 (conda-forge, linux-64)
sphinx: 9.2.0
(for a full env see https://github.com/pydata/xarray/actions/runs/40041611450/job/120713798864#step:3:1830 (lines 1830-2055))
CPython versions tested on:
3.15
Operating systems tested on:
Linux
Linked PRs
- gh-160615
- Vorherrschende Sprache
- Python
- Sterne
- 77.7k
- Forks
- 38.3k
- Ø Merge
- 14 Std. 29 Min.
- Gemergte PRs (30 T.)
- 699
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/cpython
-
topic-socket type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
python/cpython#160561 · 7 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
tests topic-profiling type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
python/cpython#160334 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
extension-modules type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
interpreter-core type-feature
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
python/cpython#160109 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
extension-modules type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
python/cpython#160001 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
request-theme
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 66/100
LizardByte/ThemerrDB#9575 ·
Maintainer antworten meist innerhalb von 1 Tag
-
author-page correction
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
acl-org/acl-anthology#10599 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
zilliztech/memsearch#818 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[FAQ] Commit ID for ProjectsEvtl. vergeben @github-actions hat das heute übernommen. Offenfaq-proposal
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
DataTalksClub/faq#503 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-freeEvtl. vergeben @Aaqibhafeezkhan hat das heute übernommen. Offenbeginner documentation good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
BistaDinesh03/critique#164 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag