mirror of
https://github.com/python/cpython.git
synced 2026-04-14 15:50:50 +00:00
Implement _PyTuple_FromPair() and _PyTuple_FromPairSteal(). Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
39 lines
853 B
C
39 lines
853 B
C
#include "parts.h"
|
|
|
|
#include "pycore_tuple.h"
|
|
|
|
|
|
static PyObject *
|
|
tuple_from_pair(PyObject *Py_UNUSED(module), PyObject *args)
|
|
{
|
|
PyObject *first, *second;
|
|
if (!PyArg_ParseTuple(args, "OO", &first, &second)) {
|
|
return NULL;
|
|
}
|
|
|
|
return _PyTuple_FromPair(first, second);
|
|
}
|
|
|
|
static PyObject *
|
|
tuple_from_pair_steal(PyObject *Py_UNUSED(module), PyObject *args)
|
|
{
|
|
PyObject *first, *second;
|
|
if (!PyArg_ParseTuple(args, "OO", &first, &second)) {
|
|
return NULL;
|
|
}
|
|
|
|
return _PyTuple_FromPairSteal(Py_NewRef(first), Py_NewRef(second));
|
|
}
|
|
|
|
|
|
static PyMethodDef test_methods[] = {
|
|
{"tuple_from_pair", tuple_from_pair, METH_VARARGS},
|
|
{"tuple_from_pair_steal", tuple_from_pair_steal, METH_VARARGS},
|
|
{NULL},
|
|
};
|
|
|
|
int
|
|
_PyTestInternalCapi_Init_Tuple(PyObject *m)
|
|
{
|
|
return PyModule_AddFunctions(m, test_methods);
|
|
}
|