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

port PyErr::from_type to Bound API #3885

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Conversation

Icxolu
Copy link
Contributor

@Icxolu Icxolu commented Feb 22, 2024

Part of #3684

This ports PyErr::from_type to the new Bound API.

@Icxolu Icxolu added the CI-skip-changelog Skip checking changelog entry label Feb 22, 2024
@@ -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
Copy link
Contributor Author

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...

Copy link
Member

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())

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks!

@davidhewitt davidhewitt added this pull request to the merge queue Feb 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 23, 2024
@davidhewitt davidhewitt added this pull request to the merge queue Feb 23, 2024
Merged via the queue into PyO3:main with commit 6a81587 Feb 23, 2024
38 of 41 checks passed
@Icxolu Icxolu deleted the pyerr-from-type branch February 24, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants