-
Notifications
You must be signed in to change notification settings - Fork 778
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
Support specifying __name__ and __doc__ in PyCFunction::new_closure #2665
Labels
Comments
Sure thing, we already did similar to A PR to change |
dalcde
added a commit
to dalcde/pyo3
that referenced
this issue
Oct 15, 2022
These arguments accept either a &'static str or an owned string (or more generally, anything implementing Into<Cow<'static, str>>. PyCFunction::new and PyCFunction::new_with_keywords are also modified to support owned strings. The main breaking change outside of impl_ is the modified function signature of new_closure. The new and new_with_keywords function now take more general arguments, which is backwards compatible but might break type inference in rare cases. Fixes PyO3#2665
dalcde
added a commit
to dalcde/pyo3
that referenced
this issue
Oct 15, 2022
These arguments accept either a &'static str or an owned string (or more generally, anything implementing Into<Cow<'static, str>>. PyCFunction::new and PyCFunction::new_with_keywords are also modified to support owned strings. The main breaking change outside of impl_ is the modified function signature of new_closure. The new and new_with_keywords function now take more general arguments, which is backwards compatible but might break type inference in rare cases. Fixes PyO3#2665
dalcde
added a commit
to dalcde/pyo3
that referenced
this issue
Oct 15, 2022
dalcde
added a commit
to dalcde/pyo3
that referenced
this issue
Oct 29, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems fairly easy to support if we only accept
&'static str
as thearguments. These arguments are mostly useful only when the function lives
forever, so users who have an owned string can simply leak it to get a
&'static str
.I'm not sure what the correct API change would be. Having e.g.
PyCFunction::new_closure_with_name_and_doc
would be backwards compatible butthe duplication of APIs could be annoying in the long run.
The text was updated successfully, but these errors were encountered: