-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise codec errors when casting to std::string #2903
Conversation
1b02928
to
e1abcb6
Compare
Allow the codec's exception to be raised instead of RuntimeError when casting from py::str to std::string. PY2 allows ucs surrogates in UTF-8 conversion Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: Shane Loretz <[email protected]>
e1abcb6
to
8dd8461
Compare
Hi @Skylion007, consider this approved also by me, but ideally I'd run this through the Google-internal global testing (which includes testing a large number of open source packages) before merging. Is it OK with you to wait a few hours? In the past we had a couple cases with a surprising number of hiccups caused by similar changes. I feel this one will be fine, but good to be sure by testing first. |
@rwgk Sure, go ahead. |
Description
This allows the codec's exception to be raised instead of
RuntimeError
when casting frompy::str
tostd::string
. I ran into this when porting a CPython extention to pybind11 with an existing test that expected aUnicodeEncodeError
when given a string with UCS surrogate characters.Suggested changelog entry: