File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -5233,6 +5233,20 @@ PyType_Ready(PyTypeObject *type)
52335233 _PyObject_ASSERT ((PyObject * )type ,
52345234 (type -> tp_flags & Py_TPFLAGS_READYING ) == 0 );
52355235
5236+ /* Consistency checks for PEP 590:
5237+ * - Py_TPFLAGS_METHOD_DESCRIPTOR requires tp_descr_get
5238+ * - _Py_TPFLAGS_HAVE_VECTORCALL requires tp_call and
5239+ * tp_vectorcall_offset > 0
5240+ * To avoid mistakes, we require this before inheriting.
5241+ */
5242+ if (type -> tp_flags & Py_TPFLAGS_METHOD_DESCRIPTOR ) {
5243+ _PyObject_ASSERT ((PyObject * )type , type -> tp_descr_get != NULL );
5244+ }
5245+ if (type -> tp_flags & _Py_TPFLAGS_HAVE_VECTORCALL ) {
5246+ _PyObject_ASSERT ((PyObject * )type , type -> tp_vectorcall_offset > 0 );
5247+ _PyObject_ASSERT ((PyObject * )type , type -> tp_call != NULL );
5248+ }
5249+
52365250 type -> tp_flags |= Py_TPFLAGS_READYING ;
52375251
52385252#ifdef Py_TRACE_REFS
You can’t perform that action at this time.
0 commit comments