mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
fix: unicode surrogate character in Python exception message. (#4297)
* Fix & test for issue #4288 (unicode surrogate character in Python exception message). * DRY `message_unavailable_exc` * fix: add a constexpr Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com> * style: pre-commit fixes Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5bc0943ed9
commit
3a2c96bd6f
@@ -275,6 +275,20 @@ def test_local_translator(msg):
|
||||
assert msg(excinfo.value) == "this mod"
|
||||
|
||||
|
||||
def test_error_already_set_message_with_unicode_surrogate(): # Issue #4288
|
||||
assert m.error_already_set_what(RuntimeError, "\ud927") == (
|
||||
"RuntimeError: \\ud927",
|
||||
False,
|
||||
)
|
||||
|
||||
|
||||
def test_error_already_set_message_with_malformed_utf8():
|
||||
assert m.error_already_set_what(RuntimeError, b"\x80") == (
|
||||
"RuntimeError: b'\\x80'",
|
||||
False,
|
||||
)
|
||||
|
||||
|
||||
class FlakyException(Exception):
|
||||
def __init__(self, failure_point):
|
||||
if failure_point == "failure_point_init":
|
||||
|
||||
Reference in New Issue
Block a user