pybind11 seems to be computing a wrong tp_name field for the nested class' PyTypeObject in make_new_python_type(). The class ends up being named just mymodule.Attributes instead of the expected mymodule.Pet.Attributes.
This can be demonstrated: The Python interpreter uses the wrong tp_name in error messages, for example:
import mymodule
a = mymodule.Pet.Attributes()
print(a.nonexisting)
gives the following error string:
AttributeError: 'mymodule.Attributes' object has no attribute 'nonexisting'
Please let me know if you also think this needs to be fixed. If so, I would be willing to contribute a pull request.
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.11.1
Problem description
Consider the following bindings for a class
Pet
and some nested classPet.Attributes
, whichs is taken from the pybind11 docs:pybind11 seems to be computing a wrong tp_name field for the nested class' PyTypeObject in make_new_python_type(). The class ends up being named just
mymodule.Attributes
instead of the expectedmymodule.Pet.Attributes
.This can be demonstrated: The Python interpreter uses the wrong
tp_name
in error messages, for example:gives the following error string:
Please let me know if you also think this needs to be fixed. If so, I would be willing to contribute a pull request.
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Not a regression