-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
maint: disable implicit conversion of 0 to handle #4006
maint: disable implicit conversion of 0 to handle #4006
Conversation
@@ -214,6 +214,7 @@ class handle : public detail::object_api<handle> { | |||
/// Creates a ``handle`` from the given raw Python object pointer | |||
// NOLINTNEXTLINE(google-explicit-constructor) | |||
handle(PyObject *ptr) : m_ptr(ptr) {} // Allow implicit conversion from PyObject* |
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.
Maybe this is a job for enable_if
?
I'd bet though enable_if
PyObject*
won't work, is_pointer
or similar might. Or maybe to be fancy, look for ob_refcnt
in the pointee?
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.
@rwgk Hmm... can't figure out the way to construct the enable_if_t.
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.
This strategy doesn't work because it causes ambiguous overloads, which is silly since the func is deleted.
It's a can of worms indeed, but I got pretty far:
There is only one subtest that does not pass (test_make_empty_shaped_array) with this diff. Is there a chance you could help debugging that? |
Closing in favor of #4008 |
Description
Suggested changelog entry: