Commit 98def19
committed
Fix bindings of classes derived from a trampoline
Binding of deeper (>= 2 levels) class hierarchies that inherit from
a trampoline class fail in Python 3.12+. For example, in the added test
suite class ``SiameseCat``, this produces the following error message:
Critical nanobind error: nanobind::detail::nb_type_new("SiameseCat"): type construction failed: TypeError: tp_basicsize for type 'test_classes_ext.SiameseCat' (56) is too small for base 'test_classes_ext.Cat' (88)!
The trick to make Python happy is to carefully walk through the parent
classes to look for trampolines. Previously, only the direct parent was
checked.1 parent d5b05b7 commit 98def19
2 files changed
+27
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
1214 | 1231 | | |
1215 | 1232 | | |
1216 | 1233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
264 | 266 | | |
265 | 267 | | |
266 | 268 | | |
| |||
274 | 276 | | |
275 | 277 | | |
276 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
| |||
0 commit comments