Skip to content

Better error report #1965

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

Merged
merged 5 commits into from
Oct 23, 2019
Merged

Better error report #1965

merged 5 commits into from
Oct 23, 2019

Conversation

HDembinski
Copy link
Contributor

This adds better error messages when py::cast is not used correctly.

@HDembinski
Copy link
Contributor Author

This job merely had a timeout, could someone with privileges please restart it?
https://travis-ci.org/pybind/pybind11/jobs/601280214

@wjakob
Copy link
Member

wjakob commented Oct 22, 2019

I would consider an error message like that, but only if compiled in debug mode. (Analogous to other uses of fancy string manipulation throughout the library, which include a note of the sort " (please recompile in debug mode for more details)". This is to avoid code bloat.)

@wjakob
Copy link
Member

wjakob commented Oct 22, 2019

build restarted.

@HDembinski
Copy link
Contributor Author

Ok, makes sense. My solution is still not perfect though, because the type name reported is without qualifiers, eq. const T& is reported as T. This is unfortunately how the typeid operator works, it drops all those qualifiers. Unfortunately, the qualifiers are critical to debug issues with the caster.

Keeping the qualifiers will be a more involved patch, which seems better suited for a separate PR.

@HDembinski
Copy link
Contributor Author

This version now only prints the type name in a debug build.

@wjakob
Copy link
Member

wjakob commented Oct 23, 2019

Looks good, thanks! Regarding getting the extra flags: I think the easiest and most cross-platform way is to wrap the type T into some dummy template foo<T>, stringify that, and then strip of the outer parts.

@wjakob wjakob merged commit bdf6a5e into pybind:master Oct 23, 2019
@HDembinski HDembinski deleted the better_error_report branch October 23, 2019 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants