1
1
#include "parts.h"
2
+ #include "clinic/long.c.h"
3
+
4
+ /*[clinic input]
5
+ module _testcapi
6
+ [clinic start generated code]*/
7
+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=6361033e795369fc]*/
2
8
3
9
4
10
static PyObject *
@@ -40,8 +46,13 @@ raise_test_long_error(const char* msg)
40
46
41
47
#include "testcapi_long.h"
42
48
49
+ /*[clinic input]
50
+ _testcapi.test_long_api
51
+ [clinic start generated code]*/
52
+
43
53
static PyObject *
44
- test_long_api (PyObject * self , PyObject * Py_UNUSED (ignored ))
54
+ _testcapi_test_long_api_impl (PyObject * module )
55
+ /*[clinic end generated code: output=4405798ca1e9f444 input=e9b8880d7331c688]*/
45
56
{
46
57
return TESTNAME (raise_test_long_error );
47
58
}
@@ -68,8 +79,13 @@ raise_test_longlong_error(const char* msg)
68
79
69
80
#include "testcapi_long.h"
70
81
82
+ /*[clinic input]
83
+ _testcapi.test_longlong_api
84
+ [clinic start generated code]*/
85
+
71
86
static PyObject *
72
- test_longlong_api (PyObject * self , PyObject * args )
87
+ _testcapi_test_longlong_api_impl (PyObject * module )
88
+ /*[clinic end generated code: output=2b3414ba8c31dfe6 input=ccbb2a48c2b3c4a5]*/
73
89
{
74
90
return TESTNAME (raise_test_longlong_error );
75
91
}
@@ -81,13 +97,16 @@ test_longlong_api(PyObject* self, PyObject *args)
81
97
#undef F_U_TO_PY
82
98
#undef F_PY_TO_U
83
99
84
- /* Test the PyLong_AsLongAndOverflow API. General conversion to PY_LONG
85
- is tested by test_long_api_inner. This test will concentrate on proper
86
- handling of overflow.
87
- */
100
+
101
+ /*[clinic input]
102
+ _testcapi.test_long_and_overflow
103
+
104
+ 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.
105
+ [clinic start generated code]*/
88
106
89
107
static PyObject *
90
- test_long_and_overflow (PyObject * self , PyObject * Py_UNUSED (ignored ))
108
+ _testcapi_test_long_and_overflow_impl (PyObject * module )
109
+ /*[clinic end generated code: output=f8460ca115e31d8e input=0eec7ad657143d42]*/
91
110
{
92
111
PyObject * num , * one , * temp ;
93
112
long value ;
@@ -243,13 +262,15 @@ test_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
243
262
Py_RETURN_NONE ;
244
263
}
245
264
246
- /* Test the PyLong_AsLongLongAndOverflow API. General conversion to
247
- long long is tested by test_long_api_inner. This test will
248
- concentrate on proper handling of overflow.
249
- */
265
+ /*[clinic input]
266
+ _testcapi.test_long_long_and_overflow
267
+
268
+ 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.
269
+ [clinic start generated code]*/
250
270
251
271
static PyObject *
252
- test_long_long_and_overflow (PyObject * self , PyObject * Py_UNUSED (ignored ))
272
+ _testcapi_test_long_long_and_overflow_impl (PyObject * module )
273
+ /*[clinic end generated code: output=0b92330786f45483 input=96dc3e6c0cdc0475]*/
253
274
{
254
275
PyObject * num , * one , * temp ;
255
276
long long value ;
@@ -405,13 +426,15 @@ test_long_long_and_overflow(PyObject *self, PyObject *Py_UNUSED(ignored))
405
426
Py_RETURN_NONE ;
406
427
}
407
428
408
- /* Test the PyLong_As{Size,Ssize}_t API. At present this just tests that
409
- non-integer arguments are handled correctly. It should be extended to
410
- test overflow handling.
411
- */
429
+ /*[clinic input]
430
+ _testcapi.test_long_as_size_t
431
+
432
+ 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.
433
+ [clinic start generated code]*/
412
434
413
435
static PyObject *
414
- test_long_as_size_t (PyObject * self , PyObject * Py_UNUSED (ignored ))
436
+ _testcapi_test_long_as_size_t_impl (PyObject * module )
437
+ /*[clinic end generated code: output=f6490ea2b41e6173 input=47d303cdd7144351]*/
415
438
{
416
439
size_t out_u ;
417
440
Py_ssize_t out_s ;
@@ -442,9 +465,13 @@ test_long_as_size_t(PyObject *self, PyObject *Py_UNUSED(ignored))
442
465
return Py_None ;
443
466
}
444
467
468
+ /*[clinic input]
469
+ _testcapi.test_long_as_unsigned_long_long_mask
470
+ [clinic start generated code]*/
471
+
445
472
static PyObject *
446
- test_long_as_unsigned_long_long_mask (PyObject * self ,
447
- PyObject * Py_UNUSED ( ignored ))
473
+ _testcapi_test_long_as_unsigned_long_long_mask_impl (PyObject * module )
474
+ /*[clinic end generated code: output=e3e16cd0189440cc input=eb2438493ae7b9af]*/
448
475
{
449
476
unsigned long long res = PyLong_AsUnsignedLongLongMask (NULL );
450
477
@@ -462,12 +489,13 @@ test_long_as_unsigned_long_long_mask(PyObject *self,
462
489
Py_RETURN_NONE ;
463
490
}
464
491
465
- /* Test the PyLong_AsDouble API. At present this just tests that
466
- non-integer arguments are handled correctly.
467
- */
492
+ /*[clinic input]
493
+ _testcapi.test_long_as_double
494
+ [clinic start generated code] */
468
495
469
496
static PyObject *
470
- test_long_as_double (PyObject * self , PyObject * Py_UNUSED (ignored ))
497
+ _testcapi_test_long_as_double_impl (PyObject * module )
498
+ /*[clinic end generated code: output=deca0898e15adde5 input=c77bc88ef5a1de76]*/
471
499
{
472
500
double out ;
473
501
@@ -487,9 +515,13 @@ test_long_as_double(PyObject *self, PyObject *Py_UNUSED(ignored))
487
515
return Py_None ;
488
516
}
489
517
490
- /* Simple test of _PyLong_NumBits and _PyLong_Sign. */
518
+ /*[clinic input]
519
+ _testcapi.test_long_numbits
520
+ [clinic start generated code]*/
521
+
491
522
static PyObject *
492
- test_long_numbits (PyObject * self , PyObject * Py_UNUSED (ignored ))
523
+ _testcapi_test_long_numbits_impl (PyObject * module )
524
+ /*[clinic end generated code: output=9eaf8458cb15d7f7 input=265c02d48a13059e]*/
493
525
{
494
526
struct triple {
495
527
long input ;
@@ -547,14 +579,14 @@ check_long_compact_api(PyObject *self, PyObject *arg)
547
579
}
548
580
549
581
static PyMethodDef test_methods [] = {
550
- { "test_long_and_overflow" , test_long_and_overflow , METH_NOARGS },
551
- { "test_long_api" , test_long_api , METH_NOARGS },
552
- { "test_long_as_double" , test_long_as_double , METH_NOARGS },
553
- { "test_long_as_size_t" , test_long_as_size_t , METH_NOARGS },
554
- { "test_long_as_unsigned_long_long_mask" , test_long_as_unsigned_long_long_mask , METH_NOARGS },
555
- { "test_long_long_and_overflow" , test_long_long_and_overflow , METH_NOARGS },
556
- { "test_long_numbits" , test_long_numbits , METH_NOARGS },
557
- { "test_longlong_api" , test_longlong_api , METH_NOARGS },
582
+ _TESTCAPI_TEST_LONG_AND_OVERFLOW_METHODDEF
583
+ _TESTCAPI_TEST_LONG_API_METHODDEF
584
+ _TESTCAPI_TEST_LONG_AS_DOUBLE_METHODDEF
585
+ _TESTCAPI_TEST_LONG_AS_SIZE_T_METHODDEF
586
+ _TESTCAPI_TEST_LONG_AS_UNSIGNED_LONG_LONG_MASK_METHODDEF
587
+ _TESTCAPI_TEST_LONG_LONG_AND_OVERFLOW_METHODDEF
588
+ _TESTCAPI_TEST_LONG_NUMBITS_METHODDEF
589
+ _TESTCAPI_TEST_LONGLONG_API_METHODDEF
558
590
{"call_long_compact_api" , check_long_compact_api , METH_O },
559
591
{NULL },
560
592
};
0 commit comments