@@ -2954,10 +2954,10 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
29542954 PyTypeObject * type , * base ;
29552955
29562956 const PyType_Slot * slot ;
2957- Py_ssize_t nmembers , weaklistoffset , dictoffset ;
2957+ Py_ssize_t nmembers , weaklistoffset , dictoffset , vectorcalloffset ;
29582958 char * res_start ;
29592959
2960- nmembers = weaklistoffset = dictoffset = 0 ;
2960+ nmembers = weaklistoffset = dictoffset = vectorcalloffset = 0 ;
29612961 for (slot = spec -> slots ; slot -> slot ; slot ++ ) {
29622962 if (slot -> slot == Py_tp_members ) {
29632963 nmembers = 0 ;
@@ -2975,6 +2975,12 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
29752975 assert (memb -> flags == READONLY );
29762976 dictoffset = memb -> offset ;
29772977 }
2978+ if (strcmp (memb -> name , "__vectorcalloffset__" ) == 0 ) {
2979+ // The PyMemberDef must be a Py_ssize_t and readonly
2980+ assert (memb -> type == T_PYSSIZET );
2981+ assert (memb -> flags == READONLY );
2982+ vectorcalloffset = memb -> offset ;
2983+ }
29782984 }
29792985 }
29802986 }
@@ -3123,6 +3129,10 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
31233129 type -> tp_dealloc = subtype_dealloc ;
31243130 }
31253131
3132+ if (vectorcalloffset ) {
3133+ type -> tp_vectorcall_offset = vectorcalloffset ;
3134+ }
3135+
31263136 if (PyType_Ready (type ) < 0 )
31273137 goto fail ;
31283138
0 commit comments