4
4
5
5
from test .support import import_helper
6
6
7
- # Skip this test if the _testcapi module isn't available.
7
+ # Skip this test if the _testcapi and _testlimitedcapi modules isn't available.
8
8
_testcapi = import_helper .import_module ('_testcapi' )
9
+ _testlimitedcapi = import_helper .import_module ('_testlimitedcapi' )
9
10
10
11
NULL = None
11
12
@@ -56,7 +57,7 @@ def test_compact_known(self):
56
57
57
58
def test_long_check (self ):
58
59
# Test PyLong_Check()
59
- check = _testcapi .pylong_check
60
+ check = _testlimitedcapi .pylong_check
60
61
self .assertTrue (check (1 ))
61
62
self .assertTrue (check (123456789012345678901234567890 ))
62
63
self .assertTrue (check (- 1 ))
@@ -68,7 +69,7 @@ def test_long_check(self):
68
69
69
70
def test_long_checkexact (self ):
70
71
# Test PyLong_CheckExact()
71
- check = _testcapi .pylong_checkexact
72
+ check = _testlimitedcapi .pylong_checkexact
72
73
self .assertTrue (check (1 ))
73
74
self .assertTrue (check (123456789012345678901234567890 ))
74
75
self .assertTrue (check (- 1 ))
@@ -80,7 +81,7 @@ def test_long_checkexact(self):
80
81
81
82
def test_long_fromdouble (self ):
82
83
# Test PyLong_FromDouble()
83
- fromdouble = _testcapi .pylong_fromdouble
84
+ fromdouble = _testlimitedcapi .pylong_fromdouble
84
85
float_max = sys .float_info .max
85
86
for value in (5.0 , 5.1 , 5.9 , - 5.1 , - 5.9 , 0.0 , - 0.0 , float_max , - float_max ):
86
87
with self .subTest (value = value ):
@@ -91,7 +92,7 @@ def test_long_fromdouble(self):
91
92
92
93
def test_long_fromvoidptr (self ):
93
94
# Test PyLong_FromVoidPtr()
94
- fromvoidptr = _testcapi .pylong_fromvoidptr
95
+ fromvoidptr = _testlimitedcapi .pylong_fromvoidptr
95
96
obj = object ()
96
97
x = fromvoidptr (obj )
97
98
y = fromvoidptr (NULL )
@@ -103,7 +104,7 @@ def test_long_fromvoidptr(self):
103
104
104
105
def test_long_fromstring (self ):
105
106
# Test PyLong_FromString()
106
- fromstring = _testcapi .pylong_fromstring
107
+ fromstring = _testlimitedcapi .pylong_fromstring
107
108
self .assertEqual (fromstring (b'123' , 10 ), (123 , 3 ))
108
109
self .assertEqual (fromstring (b'cafe' , 16 ), (0xcafe , 4 ))
109
110
self .assertEqual (fromstring (b'xyz' , 36 ), (44027 , 3 ))
@@ -163,7 +164,7 @@ def test_long_fromunicodeobject(self):
163
164
164
165
def test_long_asint (self ):
165
166
# Test PyLong_AsInt()
166
- PyLong_AsInt = _testcapi .PyLong_AsInt
167
+ PyLong_AsInt = _testlimitedcapi .PyLong_AsInt
167
168
from _testcapi import INT_MIN , INT_MAX
168
169
169
170
# round trip (object -> int -> object)
@@ -186,7 +187,7 @@ def test_long_asint(self):
186
187
187
188
def test_long_aslong (self ):
188
189
# Test PyLong_AsLong() and PyLong_FromLong()
189
- aslong = _testcapi .pylong_aslong
190
+ aslong = _testlimitedcapi .pylong_aslong
190
191
from _testcapi import LONG_MIN , LONG_MAX
191
192
# round trip (object -> long -> object)
192
193
for value in (LONG_MIN , LONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -206,7 +207,7 @@ def test_long_aslong(self):
206
207
207
208
def test_long_aslongandoverflow (self ):
208
209
# Test PyLong_AsLongAndOverflow()
209
- aslongandoverflow = _testcapi .pylong_aslongandoverflow
210
+ aslongandoverflow = _testlimitedcapi .pylong_aslongandoverflow
210
211
from _testcapi import LONG_MIN , LONG_MAX
211
212
# round trip (object -> long -> object)
212
213
for value in (LONG_MIN , LONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -224,7 +225,7 @@ def test_long_aslongandoverflow(self):
224
225
225
226
def test_long_asunsignedlong (self ):
226
227
# Test PyLong_AsUnsignedLong() and PyLong_FromUnsignedLong()
227
- asunsignedlong = _testcapi .pylong_asunsignedlong
228
+ asunsignedlong = _testlimitedcapi .pylong_asunsignedlong
228
229
from _testcapi import ULONG_MAX
229
230
# round trip (object -> unsigned long -> object)
230
231
for value in (ULONG_MAX , 0 , 1 , 1234 ):
@@ -244,7 +245,7 @@ def test_long_asunsignedlong(self):
244
245
245
246
def test_long_asunsignedlongmask (self ):
246
247
# Test PyLong_AsUnsignedLongMask()
247
- asunsignedlongmask = _testcapi .pylong_asunsignedlongmask
248
+ asunsignedlongmask = _testlimitedcapi .pylong_asunsignedlongmask
248
249
from _testcapi import ULONG_MAX
249
250
# round trip (object -> unsigned long -> object)
250
251
for value in (ULONG_MAX , 0 , 1 , 1234 ):
@@ -264,7 +265,7 @@ def test_long_asunsignedlongmask(self):
264
265
265
266
def test_long_aslonglong (self ):
266
267
# Test PyLong_AsLongLong() and PyLong_FromLongLong()
267
- aslonglong = _testcapi .pylong_aslonglong
268
+ aslonglong = _testlimitedcapi .pylong_aslonglong
268
269
from _testcapi import LLONG_MIN , LLONG_MAX
269
270
# round trip (object -> long long -> object)
270
271
for value in (LLONG_MIN , LLONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -284,7 +285,7 @@ def test_long_aslonglong(self):
284
285
285
286
def test_long_aslonglongandoverflow (self ):
286
287
# Test PyLong_AsLongLongAndOverflow()
287
- aslonglongandoverflow = _testcapi .pylong_aslonglongandoverflow
288
+ aslonglongandoverflow = _testlimitedcapi .pylong_aslonglongandoverflow
288
289
from _testcapi import LLONG_MIN , LLONG_MAX
289
290
# round trip (object -> long long -> object)
290
291
for value in (LLONG_MIN , LLONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -302,7 +303,7 @@ def test_long_aslonglongandoverflow(self):
302
303
303
304
def test_long_asunsignedlonglong (self ):
304
305
# Test PyLong_AsUnsignedLongLong() and PyLong_FromUnsignedLongLong()
305
- asunsignedlonglong = _testcapi .pylong_asunsignedlonglong
306
+ asunsignedlonglong = _testlimitedcapi .pylong_asunsignedlonglong
306
307
from _testcapi import ULLONG_MAX
307
308
# round trip (object -> unsigned long long -> object)
308
309
for value in (ULLONG_MAX , 0 , 1 , 1234 ):
@@ -322,7 +323,7 @@ def test_long_asunsignedlonglong(self):
322
323
323
324
def test_long_asunsignedlonglongmask (self ):
324
325
# Test PyLong_AsUnsignedLongLongMask()
325
- asunsignedlonglongmask = _testcapi .pylong_asunsignedlonglongmask
326
+ asunsignedlonglongmask = _testlimitedcapi .pylong_asunsignedlonglongmask
326
327
from _testcapi import ULLONG_MAX
327
328
# round trip (object -> unsigned long long -> object)
328
329
for value in (ULLONG_MAX , 0 , 1 , 1234 ):
@@ -342,7 +343,7 @@ def test_long_asunsignedlonglongmask(self):
342
343
343
344
def test_long_as_ssize_t (self ):
344
345
# Test PyLong_AsSsize_t() and PyLong_FromSsize_t()
345
- as_ssize_t = _testcapi .pylong_as_ssize_t
346
+ as_ssize_t = _testlimitedcapi .pylong_as_ssize_t
346
347
from _testcapi import PY_SSIZE_T_MIN , PY_SSIZE_T_MAX
347
348
# round trip (object -> Py_ssize_t -> object)
348
349
for value in (PY_SSIZE_T_MIN , PY_SSIZE_T_MAX , - 1 , 0 , 1 , 1234 ):
@@ -362,7 +363,7 @@ def test_long_as_ssize_t(self):
362
363
363
364
def test_long_as_size_t (self ):
364
365
# Test PyLong_AsSize_t() and PyLong_FromSize_t()
365
- as_size_t = _testcapi .pylong_as_size_t
366
+ as_size_t = _testlimitedcapi .pylong_as_size_t
366
367
from _testcapi import SIZE_MAX
367
368
# round trip (object -> size_t -> object)
368
369
for value in (SIZE_MAX , 0 , 1 , 1234 ):
@@ -382,7 +383,7 @@ def test_long_as_size_t(self):
382
383
383
384
def test_long_asdouble (self ):
384
385
# Test PyLong_AsDouble()
385
- asdouble = _testcapi .pylong_asdouble
386
+ asdouble = _testlimitedcapi .pylong_asdouble
386
387
MAX = int (sys .float_info .max )
387
388
for value in (- MAX , MAX , - 1 , 0 , 1 , 1234 ):
388
389
with self .subTest (value = value ):
@@ -402,8 +403,8 @@ def test_long_asdouble(self):
402
403
403
404
def test_long_asvoidptr (self ):
404
405
# Test PyLong_AsVoidPtr()
405
- fromvoidptr = _testcapi .pylong_fromvoidptr
406
- asvoidptr = _testcapi .pylong_asvoidptr
406
+ fromvoidptr = _testlimitedcapi .pylong_fromvoidptr
407
+ asvoidptr = _testlimitedcapi .pylong_asvoidptr
407
408
obj = object ()
408
409
x = fromvoidptr (obj )
409
410
y = fromvoidptr (NULL )
0 commit comments