@@ -2954,10 +2954,10 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
2954
2954
PyTypeObject * type , * base ;
2955
2955
2956
2956
const PyType_Slot * slot ;
2957
- Py_ssize_t nmembers , weaklistoffset , dictoffset ;
2957
+ Py_ssize_t nmembers , weaklistoffset , dictoffset , vectorcalloffset ;
2958
2958
char * res_start ;
2959
2959
2960
- nmembers = weaklistoffset = dictoffset = 0 ;
2960
+ nmembers = weaklistoffset = dictoffset = vectorcalloffset = 0 ;
2961
2961
for (slot = spec -> slots ; slot -> slot ; slot ++ ) {
2962
2962
if (slot -> slot == Py_tp_members ) {
2963
2963
nmembers = 0 ;
@@ -2975,6 +2975,12 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
2975
2975
assert (memb -> flags == READONLY );
2976
2976
dictoffset = memb -> offset ;
2977
2977
}
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
+ }
2978
2984
}
2979
2985
}
2980
2986
}
@@ -3123,6 +3129,10 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
3123
3129
type -> tp_dealloc = subtype_dealloc ;
3124
3130
}
3125
3131
3132
+ if (vectorcalloffset ) {
3133
+ type -> tp_vectorcall_offset = vectorcalloffset ;
3134
+ }
3135
+
3126
3136
if (PyType_Ready (type ) < 0 )
3127
3137
goto fail ;
3128
3138
0 commit comments