You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My colleague and I stumbled on a very confusing part of the API. When calling pybind11::weakref with a single argument that is of type py::object as such:
This is caused by the fact that the weakref constructor is explicit and the copy constructor is called instead. The result is that no weakref is created. This is very confusing. The copy constructor should allow only to copy weakref. May be by using a private copy constructor that takes an object and an public copy constructor that takes a weakref.
After some discussion on gitter, it seems that #2349 will solve this issue by raising a TypeError. However, the API would be still awkward.
The text was updated successfully, but these errors were encountered:
I agree, here (also having taken part in the discussion on Gitter). Normally, handle and object are kind of interchangeable, but not here? We have a similar problem for py::str, btw, where the extra constructor applies str to the passed handle.
Uh oh!
There was an error while loading. Please reload this page.
My colleague and I stumbled on a very confusing part of the API. When calling pybind11::weakref with a single argument that is of type py::object as such:
Here is a correct way to call it:
This is caused by the fact that the weakref constructor is explicit and the copy constructor is called instead. The result is that no weakref is created. This is very confusing. The copy constructor should allow only to copy weakref. May be by using a private copy constructor that takes an object and an public copy constructor that takes a weakref.
After some discussion on gitter, it seems that #2349 will solve this issue by raising a TypeError. However, the API would be still awkward.
The text was updated successfully, but these errors were encountered: