Skip to content

Commit 75c5ea1

Browse files
assert Py_TPFLAGS_DISALLOW_INSTANTIATION on initial=0
1 parent 5d1d9b5 commit 75c5ea1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Objects/typeobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9018,9 +9018,13 @@ type_ready_set_new(PyTypeObject *type, int initial)
90189018
default also inherit object.__new__. */
90199019
if (type->tp_new == NULL
90209020
&& base == &PyBaseObject_Type
9021-
&& !(type->tp_flags & Py_TPFLAGS_HEAPTYPE) && initial)
9021+
&& !(type->tp_flags & Py_TPFLAGS_HEAPTYPE))
90229022
{
9023-
type_add_flags(type, Py_TPFLAGS_DISALLOW_INSTANTIATION);
9023+
if (initial) {
9024+
type_add_flags(type, Py_TPFLAGS_DISALLOW_INSTANTIATION);
9025+
} else {
9026+
assert(type->tp_flags & Py_TPFLAGS_DISALLOW_INSTANTIATION);
9027+
}
90249028
}
90259029

90269030
if (!(type->tp_flags & Py_TPFLAGS_DISALLOW_INSTANTIATION)) {

0 commit comments

Comments
 (0)