Skip to content

Commit aeba03d

Browse files
don't set zero basicsize with abi3t (#6105)
* don't set zero basicsize with `abi3t` * Update src/pyclass/create_type_object.rs Co-authored-by: Bas Schoenmaeckers <7943856+bschoenmaeckers@users.noreply.github.com> --------- Co-authored-by: Bas Schoenmaeckers <7943856+bschoenmaeckers@users.noreply.github.com>
1 parent 654cc58 commit aeba03d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/pyclass/create_type_object.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,15 @@ impl PyTypeBuilder {
514514
ffi::PySlot_UINT64(ffi::Py_tp_flags, flags.into()),
515515
ffi::PySlot_DATA(ffi::Py_tp_slots, self.slots.as_mut_ptr().cast::<c_void>()),
516516
match basicsize {
517-
0.. => ffi::PySlot_SIZE(ffi::Py_tp_basicsize, basicsize),
517+
1.. => ffi::PySlot_SIZE(ffi::Py_tp_basicsize, basicsize),
518+
// zero size; don't set the slot at all, the VM will use the parent size
519+
//
520+
// This can *ONLY* be hit on the variable-sized case with a rust ZST,
521+
// as a fully-sized case will always have size at least equal to `PyObject`
522+
0 => ffi::PySlot_END(),
518523
..0 => ffi::PySlot_SIZE(ffi::Py_tp_extra_basicsize, -basicsize),
519524
},
525+
// NB: insert additional slots BEFORE `basicsize` slot as it might be null
520526
ffi::PySlot_END(),
521527
];
522528

0 commit comments

Comments
 (0)