Re: [PATCH] docs: kfigure.py: don't crash during read/write
From: Jonathan Corbet
Date: Wed Aug 20 2025 - 08:46:26 EST
Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> writes:
> By default, Python does a very bad job when reading/writing
> from files, as it tries to enforce that the character is < 128.
> Nothing prevents a SVG file to contain, for instance, a comment
> with an utf-8 accented copyright notice - or even an utf-8
> invalid char.
Do you have a locale that expects everything to be ASCII? This seems a
bit weird. I would expect utf8 to work by default these days.
> While testing PDF and html builds, I recently faced one build
> that got an error at kfigure.py saying that a char was > 128,
> crashing PDF output.
>
> To avoid such issues, let's use PEP 383 subrogate escape encoding
> to prevent read/write errors on such cases.
Being explicit about utf8 is good...but where are the errors coming
from? Is this really a utf8 file?
Thanks,
jon