mirror of https://github.com/pybind/pybind11.git
Compare commits
2 Commits
589ed702a2
...
ab72f87b0d
Author | SHA1 | Date |
---|---|---|
Francesco Biscani | ab72f87b0d | |
Francesco Biscani | 8e54167aa7 |
|
@ -1076,9 +1076,13 @@ protected:
|
|||
msg += '\n';
|
||||
}
|
||||
msg += "\nInvoked with: ";
|
||||
constexpr auto max_args_repr_size = 5000u;
|
||||
const auto orig_msg_size = msg.size();
|
||||
auto args_ = reinterpret_borrow<tuple>(args_in);
|
||||
bool some_args = false;
|
||||
for (size_t ti = overloads->is_constructor ? 1 : 0; ti < args_.size(); ++ti) {
|
||||
for (size_t ti = overloads->is_constructor ? 1 : 0;
|
||||
ti < args_.size() && msg.size() - orig_msg_size <= max_args_repr_size;
|
||||
++ti) {
|
||||
if (!some_args) {
|
||||
some_args = true;
|
||||
} else {
|
||||
|
@ -1090,7 +1094,7 @@ protected:
|
|||
msg += "<repr raised Error>";
|
||||
}
|
||||
}
|
||||
if (kwargs_in) {
|
||||
if (kwargs_in && msg.size() - orig_msg_size <= max_args_repr_size) {
|
||||
auto kwargs = reinterpret_borrow<dict>(kwargs_in);
|
||||
if (!kwargs.empty()) {
|
||||
if (some_args) {
|
||||
|
@ -1099,6 +1103,10 @@ protected:
|
|||
msg += "kwargs: ";
|
||||
bool first = true;
|
||||
for (const auto &kwarg : kwargs) {
|
||||
if (msg.size() - orig_msg_size > max_args_repr_size) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
@ -1114,6 +1122,10 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
if (msg.size() - orig_msg_size > max_args_repr_size) {
|
||||
msg += "...";
|
||||
}
|
||||
|
||||
append_note_if_missing_header_is_suspected(msg);
|
||||
// Attach additional error info to the exception if supported
|
||||
if (PyErr_Occurred()) {
|
||||
|
|
Loading…
Reference in New Issue