-
Notifications
You must be signed in to change notification settings - Fork 769
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
port PyErr::from_type
to Bound
API
#3885
Conversation
@@ -192,11 +207,11 @@ impl PyErr { | |||
/// If `ty` does not inherit from `BaseException`, then a `TypeError` will be returned. | |||
/// | |||
/// If calling `ty` with `args` raises an exception, that exception will be returned. | |||
pub fn from_type<A>(ty: &PyType, args: A) -> PyErr | |||
pub fn from_type_bound<A>(ty: Bound<'_, PyType>, args: A) -> PyErr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably this could also just take a Py<PyType>
, but then we would need a different name I guess...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, yes. How about new_with_type
?
I'm also kinda ok with leaving this as-is; it's a bit easier to get a Bound<PyType>
than a Py<PyType>
(e.g. with PyAnyMethods::get_type()
, or just .downcast_into()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you prefer? I think its fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity of migration let's just keep this as is, given there's no obvious answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Part of #3684
This ports
PyErr::from_type
to the newBound
API.