Files
opencv-MIRROR/modules/python/src2
Kari Pikkarainen ec2101a1a1 python: raise instead of crashing on strings that can't be encoded as UTF-8
getUnicodeString passed the result of PyUnicode_AsUTF8String to
PyBytes_Check without a NULL check. For a str with a lone surrogate
(for example '\udcff') the encoder fails and returns NULL, so passing such
a string to any std::string argument (putText, getTextSize, ...) crashed
the interpreter. It now returns false with the UnicodeEncodeError set,
which the converters already report.

Prepared with AI assistance (Claude Code); I reviewed the change and the verification results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 06:59:07 -08:00
..