PyErr_Clear();
return 0;
}
- pargs = PyTuple_Pack(2, name, bases);
- if (pargs == NULL) {
+ pargs = PyTuple_New(2);
+ if (!pargs) {
Py_DECREF(prep);
return -1;
}
+ Py_INCREF(name);
+ Py_INCREF(bases);
+ PyTuple_SET_ITEM(pargs, 0, name);
+ PyTuple_SET_ITEM(pargs, 1, bases);
ns = PyEval_CallObjectWithKeywords(prep, pargs, mkw);
Py_DECREF(pargs);
Py_DECREF(prep);
Py_INCREF(metaclass);
}
if (mkw && PyDict_Size(mkw) > 0) {
- PyObject *margs;
- margs = PyTuple_Pack(3, name, bases, dict, NULL);
+ PyObject *margs = PyTuple_New(3);
+ Py_INCREF(name);
+ Py_INCREF(bases);
+ Py_INCREF(dict);
+ PyTuple_SET_ITEM(margs, 0, name);
+ PyTuple_SET_ITEM(margs, 1, bases);
+ PyTuple_SET_ITEM(margs, 2, dict);
result = PyEval_CallObjectWithKeywords(metaclass, margs, mkw);
Py_DECREF(margs);
} else {