-
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
Enable specifyingpy::metaclass(PyType_Type)
without a C/C++ cast.
#5015
base: master
Are you sure you want to change the base?
Conversation
This seems quite benign as a change. But I think it could be useful to add somewhere in the docs that types can be specified this way, and that the basic PyType_Type metaclass has some friction points but offers compatibility to ABCMeta. |
7318d76
to
dfe3eac
Compare
dfe3eac
to
cf230fb
Compare
Done: cf230fb |
Is "and can also lead to other surprising issues" appropriate given that is text that users will read in the documentation? It seems a bit like fear-mongering that pybind11 is doing something bad by default. Whereas the default metaclass works perfectly fine except in fairly narrow niche cases that you seem to be running into in the Google ecosystem (nobody had ever brought up the issue you raised before). And there are good technical reasons why it this custom metaclass is used. I think it's also worth pointing out in the docstring that if compatibility with |
5b7ebd7
to
0d29c62
Compare
I replaced "issues" (which I understood as something that simply needs attention) with "side effects" (the evidence is in the PR description; I'm not mentioning #1359 because I don't understand it enough, but there is a good chance that it is also related).
I did already (although I had accidentally left out one
|
I just converted this PR back to Draft mode because we (@Yhg1s and myself) just decided that PyCLIF-pybind11 will use the default pybind11 metaclass, and that we'll change client code to make that possible (sprawling changes around the Google code base). How exactly I'm still figuring out. The main idea is to use a metaclass that has both |
The default pybind11 metaclass pretends that it lives in module A module with the name I wouldn't call that bad, but it does not look right either, especially because it is why MATLAB is falling over: We need do consider: there may be multiple ABI-incompatible metaclasses in a given process. We cannot simply create a Or could we? — By ensuring that Or could/should we add the ABI key to the name? (e.g. |
Pretty certain: we cannot. Because |
Description
py::metaclass(PyType_Type)
is useful to resolve these problems:metaclass conflict
in the added tests.This PR makes it possible to simply specify
py::metaclass(PyType_Type)
instead ofpy::metaclass((PyObject *) &PyType_Type)
.This PR also adds comments regarding abc.ABCMeta compatibility.
Note for completeness: the added tests are a partial backport from google/pywrapcc#30094.
Suggested changelog entry:
It is now possible to specify ``py::metaclass(PyType_Type)`` without a C/C++ cast.