Skip to content
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

Avoid a crash in nb::try_cast<T>(nb::none()) #386

Merged
merged 2 commits into from Dec 15, 2023

Conversation

oremanj
Copy link
Contributor

@oremanj oremanj commented Dec 14, 2023

Previously it could raise an exception from the type_caster's conversion operator, which would then crash the program due to try_cast being noexcept.

try {
out = caster.operator detail::cast_t<T>();
return true;
} catch (...) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you be more specific in catching a particular exception here? I think it should be nb::next_overload.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. It's nb::builtin_exception since all the more-specific choices turned into wrappers around that one.

@wjakob wjakob merged commit 94fa30e into wjakob:master Dec 15, 2023
21 checks passed
@wjakob
Copy link
Owner

wjakob commented Dec 15, 2023

Thanks!

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.

None yet

2 participants