44
55from test .support import import_helper
66
7- # Skip this test if the _testcapi module isn't available.
7+ # Skip this test if the _testcapi and _testlimitedcapi modules isn't available.
88_testcapi = import_helper .import_module ('_testcapi' )
9+ _testlimitedcapi = import_helper .import_module ('_testlimitedcapi' )
910
1011NULL = None
1112
@@ -56,7 +57,7 @@ def test_compact_known(self):
5657
5758 def test_long_check (self ):
5859 # Test PyLong_Check()
59- check = _testcapi .pylong_check
60+ check = _testlimitedcapi .pylong_check
6061 self .assertTrue (check (1 ))
6162 self .assertTrue (check (123456789012345678901234567890 ))
6263 self .assertTrue (check (- 1 ))
@@ -68,7 +69,7 @@ def test_long_check(self):
6869
6970 def test_long_checkexact (self ):
7071 # Test PyLong_CheckExact()
71- check = _testcapi .pylong_checkexact
72+ check = _testlimitedcapi .pylong_checkexact
7273 self .assertTrue (check (1 ))
7374 self .assertTrue (check (123456789012345678901234567890 ))
7475 self .assertTrue (check (- 1 ))
@@ -80,7 +81,7 @@ def test_long_checkexact(self):
8081
8182 def test_long_fromdouble (self ):
8283 # Test PyLong_FromDouble()
83- fromdouble = _testcapi .pylong_fromdouble
84+ fromdouble = _testlimitedcapi .pylong_fromdouble
8485 float_max = sys .float_info .max
8586 for value in (5.0 , 5.1 , 5.9 , - 5.1 , - 5.9 , 0.0 , - 0.0 , float_max , - float_max ):
8687 with self .subTest (value = value ):
@@ -91,7 +92,7 @@ def test_long_fromdouble(self):
9192
9293 def test_long_fromvoidptr (self ):
9394 # Test PyLong_FromVoidPtr()
94- fromvoidptr = _testcapi .pylong_fromvoidptr
95+ fromvoidptr = _testlimitedcapi .pylong_fromvoidptr
9596 obj = object ()
9697 x = fromvoidptr (obj )
9798 y = fromvoidptr (NULL )
@@ -103,7 +104,7 @@ def test_long_fromvoidptr(self):
103104
104105 def test_long_fromstring (self ):
105106 # Test PyLong_FromString()
106- fromstring = _testcapi .pylong_fromstring
107+ fromstring = _testlimitedcapi .pylong_fromstring
107108 self .assertEqual (fromstring (b'123' , 10 ), (123 , 3 ))
108109 self .assertEqual (fromstring (b'cafe' , 16 ), (0xcafe , 4 ))
109110 self .assertEqual (fromstring (b'xyz' , 36 ), (44027 , 3 ))
@@ -163,7 +164,7 @@ def test_long_fromunicodeobject(self):
163164
164165 def test_long_asint (self ):
165166 # Test PyLong_AsInt()
166- PyLong_AsInt = _testcapi .PyLong_AsInt
167+ PyLong_AsInt = _testlimitedcapi .PyLong_AsInt
167168 from _testcapi import INT_MIN , INT_MAX
168169
169170 # round trip (object -> int -> object)
@@ -186,7 +187,7 @@ def test_long_asint(self):
186187
187188 def test_long_aslong (self ):
188189 # Test PyLong_AsLong() and PyLong_FromLong()
189- aslong = _testcapi .pylong_aslong
190+ aslong = _testlimitedcapi .pylong_aslong
190191 from _testcapi import LONG_MIN , LONG_MAX
191192 # round trip (object -> long -> object)
192193 for value in (LONG_MIN , LONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -206,7 +207,7 @@ def test_long_aslong(self):
206207
207208 def test_long_aslongandoverflow (self ):
208209 # Test PyLong_AsLongAndOverflow()
209- aslongandoverflow = _testcapi .pylong_aslongandoverflow
210+ aslongandoverflow = _testlimitedcapi .pylong_aslongandoverflow
210211 from _testcapi import LONG_MIN , LONG_MAX
211212 # round trip (object -> long -> object)
212213 for value in (LONG_MIN , LONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -224,7 +225,7 @@ def test_long_aslongandoverflow(self):
224225
225226 def test_long_asunsignedlong (self ):
226227 # Test PyLong_AsUnsignedLong() and PyLong_FromUnsignedLong()
227- asunsignedlong = _testcapi .pylong_asunsignedlong
228+ asunsignedlong = _testlimitedcapi .pylong_asunsignedlong
228229 from _testcapi import ULONG_MAX
229230 # round trip (object -> unsigned long -> object)
230231 for value in (ULONG_MAX , 0 , 1 , 1234 ):
@@ -244,7 +245,7 @@ def test_long_asunsignedlong(self):
244245
245246 def test_long_asunsignedlongmask (self ):
246247 # Test PyLong_AsUnsignedLongMask()
247- asunsignedlongmask = _testcapi .pylong_asunsignedlongmask
248+ asunsignedlongmask = _testlimitedcapi .pylong_asunsignedlongmask
248249 from _testcapi import ULONG_MAX
249250 # round trip (object -> unsigned long -> object)
250251 for value in (ULONG_MAX , 0 , 1 , 1234 ):
@@ -264,7 +265,7 @@ def test_long_asunsignedlongmask(self):
264265
265266 def test_long_aslonglong (self ):
266267 # Test PyLong_AsLongLong() and PyLong_FromLongLong()
267- aslonglong = _testcapi .pylong_aslonglong
268+ aslonglong = _testlimitedcapi .pylong_aslonglong
268269 from _testcapi import LLONG_MIN , LLONG_MAX
269270 # round trip (object -> long long -> object)
270271 for value in (LLONG_MIN , LLONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -284,7 +285,7 @@ def test_long_aslonglong(self):
284285
285286 def test_long_aslonglongandoverflow (self ):
286287 # Test PyLong_AsLongLongAndOverflow()
287- aslonglongandoverflow = _testcapi .pylong_aslonglongandoverflow
288+ aslonglongandoverflow = _testlimitedcapi .pylong_aslonglongandoverflow
288289 from _testcapi import LLONG_MIN , LLONG_MAX
289290 # round trip (object -> long long -> object)
290291 for value in (LLONG_MIN , LLONG_MAX , - 1 , 0 , 1 , 1234 ):
@@ -302,7 +303,7 @@ def test_long_aslonglongandoverflow(self):
302303
303304 def test_long_asunsignedlonglong (self ):
304305 # Test PyLong_AsUnsignedLongLong() and PyLong_FromUnsignedLongLong()
305- asunsignedlonglong = _testcapi .pylong_asunsignedlonglong
306+ asunsignedlonglong = _testlimitedcapi .pylong_asunsignedlonglong
306307 from _testcapi import ULLONG_MAX
307308 # round trip (object -> unsigned long long -> object)
308309 for value in (ULLONG_MAX , 0 , 1 , 1234 ):
@@ -322,7 +323,7 @@ def test_long_asunsignedlonglong(self):
322323
323324 def test_long_asunsignedlonglongmask (self ):
324325 # Test PyLong_AsUnsignedLongLongMask()
325- asunsignedlonglongmask = _testcapi .pylong_asunsignedlonglongmask
326+ asunsignedlonglongmask = _testlimitedcapi .pylong_asunsignedlonglongmask
326327 from _testcapi import ULLONG_MAX
327328 # round trip (object -> unsigned long long -> object)
328329 for value in (ULLONG_MAX , 0 , 1 , 1234 ):
@@ -342,7 +343,7 @@ def test_long_asunsignedlonglongmask(self):
342343
343344 def test_long_as_ssize_t (self ):
344345 # 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
346347 from _testcapi import PY_SSIZE_T_MIN , PY_SSIZE_T_MAX
347348 # round trip (object -> Py_ssize_t -> object)
348349 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):
362363
363364 def test_long_as_size_t (self ):
364365 # 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
366367 from _testcapi import SIZE_MAX
367368 # round trip (object -> size_t -> object)
368369 for value in (SIZE_MAX , 0 , 1 , 1234 ):
@@ -382,7 +383,7 @@ def test_long_as_size_t(self):
382383
383384 def test_long_asdouble (self ):
384385 # Test PyLong_AsDouble()
385- asdouble = _testcapi .pylong_asdouble
386+ asdouble = _testlimitedcapi .pylong_asdouble
386387 MAX = int (sys .float_info .max )
387388 for value in (- MAX , MAX , - 1 , 0 , 1 , 1234 ):
388389 with self .subTest (value = value ):
@@ -402,8 +403,8 @@ def test_long_asdouble(self):
402403
403404 def test_long_asvoidptr (self ):
404405 # Test PyLong_AsVoidPtr()
405- fromvoidptr = _testcapi .pylong_fromvoidptr
406- asvoidptr = _testcapi .pylong_asvoidptr
406+ fromvoidptr = _testlimitedcapi .pylong_fromvoidptr
407+ asvoidptr = _testlimitedcapi .pylong_asvoidptr
407408 obj = object ()
408409 x = fromvoidptr (obj )
409410 y = fromvoidptr (NULL )
0 commit comments