mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-13 09:46:10 +00:00
fix: throwing repr caused a segfault (#2389)
* fix: throwing repr caused a segfault * fixup! ci: include Python 3.9 RC1 (#2387)
This commit is contained in:
@@ -776,7 +776,11 @@ protected:
|
||||
for (size_t ti = overloads->is_constructor ? 1 : 0; ti < args_.size(); ++ti) {
|
||||
if (!some_args) some_args = true;
|
||||
else msg += ", ";
|
||||
msg += pybind11::repr(args_[ti]);
|
||||
try {
|
||||
msg += pybind11::repr(args_[ti]);
|
||||
} catch (const error_already_set&) {
|
||||
msg += "<repr raised Error>";
|
||||
}
|
||||
}
|
||||
if (kwargs_in) {
|
||||
auto kwargs = reinterpret_borrow<dict>(kwargs_in);
|
||||
@@ -787,7 +791,12 @@ protected:
|
||||
for (auto kwarg : kwargs) {
|
||||
if (first) first = false;
|
||||
else msg += ", ";
|
||||
msg += pybind11::str("{}={!r}").format(kwarg.first, kwarg.second);
|
||||
msg += pybind11::str("{}=").format(kwarg.first);
|
||||
try {
|
||||
msg += pybind11::repr(kwarg.second);
|
||||
} catch (const error_already_set&) {
|
||||
msg += "<repr raised Error>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user