@@ -104,38 +104,42 @@ all_type_info_get_cache(PyTypeObject *type);
104104
105105// Populates a just-created cache entry.
106106PYBIND11_NOINLINE void all_type_info_populate (PyTypeObject *t, std::vector<type_info *> &bases) {
107+ printf (" \n LOOOK all_type_info_populate[ %s:%d\n " , __FILE__, __LINE__); fflush (stdout);
107108 std::vector<PyTypeObject *> check;
108109 for (handle parent : reinterpret_borrow<tuple>(t->tp_bases )) {
109110 check.push_back ((PyTypeObject *) parent.ptr ());
110111 }
112+ printf (" \n LOOOK:REG:POP tp_name=%s check.size()=%lu %s:%d\n " , t->tp_name , (unsigned long ) check.size (), __FILE__, __LINE__); fflush (stdout);
111113
112114 auto const &type_dict = get_internals ().registered_types_py ;
113115 for (size_t i = 0 ; i < check.size (); i++) {
114- auto *type = check[i];
116+ PyTypeObject *type = check[i];
115117 // Ignore Python2 old-style class super type:
116118 if (!PyType_Check ((PyObject *) type)) {
117119 continue ;
118120 }
119121
120122 // Check `type` in the current set of registered python types:
121123 auto it = type_dict.find (type);
124+ printf (" \n LOOOK type_dict.find(type) tp_name=%s found=%s %s:%d\n " , type->tp_name , (it != type_dict.end () ? " yes" : " no" ), __FILE__, __LINE__); fflush (stdout);
122125 if (it != type_dict.end ()) {
123126 // We found a cache entry for it, so it's either pybind-registered or has pre-computed
124127 // pybind bases, but we have to make sure we haven't already seen the type(s) before:
125128 // we want to follow Python/virtual C++ rules that there should only be one instance of
126129 // a common base.
127- for (auto *tinfo : it->second ) {
130+ for (type_info *tinfo : it->second ) {
128131 // NB: Could use a second set here, rather than doing a linear search, but since
129132 // having a large number of immediate pybind11-registered types seems fairly
130133 // unlikely, that probably isn't worthwhile.
131134 bool found = false ;
132- for (auto *known : bases) {
135+ for (type_info *known : bases) {
133136 if (known == tinfo) {
134137 found = true ;
135138 break ;
136139 }
137140 }
138141 if (!found) {
142+ printf (" \n LOOOK:REG:ADD bases.push_back(tinfo) %s %s:%d\n " , tinfo->cpptype ->name (), __FILE__, __LINE__); fflush (stdout);
139143 bases.push_back (tinfo);
140144 }
141145 }
@@ -154,6 +158,7 @@ PYBIND11_NOINLINE void all_type_info_populate(PyTypeObject *t, std::vector<type_
154158 }
155159 }
156160 }
161+ printf (" \n LOOOK all_type_info_populate] %s:%d\n " , __FILE__, __LINE__); fflush (stdout);
157162}
158163
159164/* *
@@ -260,7 +265,14 @@ struct value_and_holder {
260265 value_and_holder (instance *i, const detail::type_info *type, size_t vpos, size_t index)
261266 : inst{i}, index{index}, type{type},
262267 vh{inst->simple_layout ? inst->simple_value_holder
263- : &inst->nonsimple .values_and_holders [vpos]} {}
268+ : &inst->nonsimple .values_and_holders [vpos]} {
269+ if (type && type->cpptype ) {
270+ const char *nm = type->cpptype ->name ();
271+ if (strcmp (nm, " N32test_python_multiple_inheritance7CppBaseE" ) == 0 || strcmp (nm, " N32test_python_multiple_inheritance7CppDrvdE" ) == 0 ) {
272+ printf (" \n LOOOK %s value_and_holder ctor %s:%d\n " , nm, __FILE__, __LINE__); fflush (stdout);
273+ }
274+ }
275+ }
264276
265277 // Default constructor (used to signal a value-and-holder not found by get_value_and_holder())
266278 value_and_holder () = default ;
@@ -286,11 +298,18 @@ struct value_and_holder {
286298 }
287299 // NOLINTNEXTLINE(readability-make-member-function-const)
288300 void set_holder_constructed (bool v = true ) {
301+ // printf("\nLOOOK set_holder_constructed inst=%lu %s %s:%d\n", reinterpret_cast<unsigned long>(inst), type->cpptype->name(), __FILE__, __LINE__); fflush(stdout);
302+ if (strcmp (" N32test_python_multiple_inheritance7CppBaseE" , type->cpptype ->name ()) == 0 ) {
303+ // long *BAD = nullptr; *BAD = 101;
304+ }
289305 if (inst->simple_layout ) {
306+ // printf("\nLOOOK %s set_holder_constructed simple_layout %s:%d\n", type->cpptype->name(), __FILE__, __LINE__); fflush(stdout);
290307 inst->simple_holder_constructed = v;
291308 } else if (v) {
309+ // printf("\nLOOOK %s set_holder_constructed v %s:%d\n", type->cpptype->name(), __FILE__, __LINE__); fflush(stdout);
292310 inst->nonsimple .status [index] |= instance::status_holder_constructed;
293311 } else {
312+ // printf("\nLOOOK %s set_holder_constructed not v %s:%d\n", type->cpptype->name(), __FILE__, __LINE__); fflush(stdout);
294313 inst->nonsimple .status [index] &= (std::uint8_t ) ~instance::status_holder_constructed;
295314 }
296315 }
0 commit comments