cpython/Modules/_testlimitedcapi/long.c

#include "pyconfig.h"   // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
   // Need limited C API 3.14 to test PyLong_AsInt64()
#define Py_LIMITED_API
#endif

#include "parts.h"
#include "util.h"
#include "clinic/long.c.h"

/*[clinic input]
module _testlimitedcapi
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2700057f9c1135ba]*/


static PyObject *
raiseTestError(const char* test_name, const char* msg)
{}

/* Tests of PyLong_{As, From}{Unsigned,}Long(), and
   PyLong_{As, From}{Unsigned,}LongLong().

   Note that the meat of the test is contained in testcapi_long.h.
   This is revolting, but delicate code duplication is worse:  "almost
   exactly the same" code is needed to test long long, but the ubiquitous
   dependence on type names makes it impossible to use a parameterized
   function.  A giant macro would be even worse than this.  A C++ template
   would be perfect.

   The "report an error" functions are deliberately not part of the #include
   file:  if the test fails, you can set a breakpoint in the appropriate
   error function directly, and crawl back from there in the debugger.
*/

#define UNBIND(X)

static PyObject *
raise_test_long_error(const char* msg)
{}

// Test PyLong_FromLong()/PyLong_AsLong()
// and PyLong_FromUnsignedLong()/PyLong_AsUnsignedLong().

#define TESTNAME
#define TYPENAME
#define F_S_TO_PY
#define F_PY_TO_S
#define F_U_TO_PY
#define F_PY_TO_U

#include "testcapi_long.h"

/*[clinic input]
_testlimitedcapi.test_long_api
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_long_api_impl(PyObject *module)
/*[clinic end generated code: output=06a2c02366d1853a input=9012b3d6a483df63]*/
{}

#undef TESTNAME
#undef TYPENAME
#undef F_S_TO_PY
#undef F_PY_TO_S
#undef F_U_TO_PY
#undef F_PY_TO_U

// Test PyLong_FromLongLong()/PyLong_AsLongLong()
// and PyLong_FromUnsignedLongLong()/PyLong_AsUnsignedLongLong().

static PyObject *
raise_test_longlong_error(const char* msg)
{}

#define TESTNAME
#define TYPENAME
#define F_S_TO_PY
#define F_PY_TO_S
#define F_U_TO_PY
#define F_PY_TO_U

#include "testcapi_long.h"

/*[clinic input]
_testlimitedcapi.test_longlong_api
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_longlong_api_impl(PyObject *module)
/*[clinic end generated code: output=8faa10e1c35214bf input=2b582a9d25bd68e7]*/
{}

#undef TESTNAME
#undef TYPENAME
#undef F_S_TO_PY
#undef F_PY_TO_S
#undef F_U_TO_PY
#undef F_PY_TO_U


/*[clinic input]
_testlimitedcapi.test_long_and_overflow

Test the PyLong_AsLongAndOverflow API.

General conversion to PY_LONG is tested by test_long_api_inner.
This test will concentrate on proper handling of overflow.
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_long_and_overflow_impl(PyObject *module)
/*[clinic end generated code: output=fdfd3c1eeabb6d14 input=e3a18791de6519fe]*/
{}

/*[clinic input]
_testlimitedcapi.test_long_long_and_overflow

Test the PyLong_AsLongLongAndOverflow API.

General conversion to long long is tested by test_long_api_inner.
This test will concentrate on proper handling of overflow.
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_long_long_and_overflow_impl(PyObject *module)
/*[clinic end generated code: output=3d2721a49c09a307 input=741c593b606cc6b3]*/
{}

/*[clinic input]
_testlimitedcapi.test_long_as_size_t

Test the PyLong_As{Size,Ssize}_t API.

At present this just tests that non-integer arguments are handled correctly.
It should be extended to test overflow handling.
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_long_as_size_t_impl(PyObject *module)
/*[clinic end generated code: output=297a9f14a42f55af input=8923d8f2038c46f4]*/
{}

/*[clinic input]
_testlimitedcapi.test_long_as_unsigned_long_long_mask
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_long_as_unsigned_long_long_mask_impl(PyObject *module)
/*[clinic end generated code: output=90be09ffeec8ecab input=17c660bd58becad5]*/
{}

/*[clinic input]
_testlimitedcapi.test_long_as_double
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_test_long_as_double_impl(PyObject *module)
/*[clinic end generated code: output=0e688c2acf224f88 input=e7b5712385064a48]*/
{}

static PyObject *
pylong_check(PyObject *module, PyObject *obj)
{}

static PyObject *
pylong_checkexact(PyObject *module, PyObject *obj)
{}

static PyObject *
pylong_fromdouble(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_fromstring(PyObject *module, PyObject *args)
{}

static PyObject *
pylong_fromvoidptr(PyObject *module, PyObject *arg)
{}

/*[clinic input]
_testlimitedcapi.PyLong_AsInt
    arg: object
    /
[clinic start generated code]*/

static PyObject *
_testlimitedcapi_PyLong_AsInt(PyObject *module, PyObject *arg)
/*[clinic end generated code: output=d91db4c1287f85fa input=32c66be86f3265a1]*/
{}

static PyObject *
pylong_aslong(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_aslongandoverflow(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asunsignedlong(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asunsignedlongmask(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_aslonglong(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_aslonglongandoverflow(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asunsignedlonglong(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asunsignedlonglongmask(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_as_ssize_t(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_as_size_t(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asdouble(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asvoidptr(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_aspid(PyObject *module, PyObject *arg)
{}


static PyObject *
pylong_asint32(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asuint32(PyObject *module, PyObject *arg)
{}


static PyObject *
pylong_asint64(PyObject *module, PyObject *arg)
{}

static PyObject *
pylong_asuint64(PyObject *module, PyObject *arg)
{}


static PyMethodDef test_methods[] =;

int
_PyTestLimitedCAPI_Init_Long(PyObject *mod)
{}