@@ -424,9 +424,9 @@ def test_long_asvoidptr(self):
424
424
self .assertRaises (OverflowError , asvoidptr , - 2 ** 1000 )
425
425
# CRASHES asvoidptr(NULL)
426
426
427
- def test_long_copybits (self ):
427
+ def test_long_asnativebytes (self ):
428
428
import math
429
- from _testcapi import pylong_copybits as copybits , SIZE_MAX
429
+ from _testcapi import pylong_asnativebytes as asnativebytes , SIZE_MAX
430
430
431
431
# Abbreviate sizeof(Py_ssize_t) to SZ because we use it a lot
432
432
SZ = int (math .ceil (math .log (SIZE_MAX + 1 ) / math .log (2 )) / 8 )
@@ -451,8 +451,8 @@ def test_long_copybits(self):
451
451
]:
452
452
with self .subTest (f"sizeof-{ v :X} " ):
453
453
buffer = bytearray (1 )
454
- self .assertEqual (expect , copybits (v , buffer , 0 , - 1 ),
455
- "PyLong_CopyBits (v, NULL, 0, -1)" )
454
+ self .assertEqual (expect , asnativebytes (v , buffer , 0 , - 1 ),
455
+ "PyLong_AsNativeBytes (v, NULL, 0, -1)" )
456
456
457
457
# We request as many bytes as `expect_be` contains, and always check
458
458
# the result (both big and little endian). We check the return value
@@ -507,16 +507,19 @@ def test_long_copybits(self):
507
507
buffer = bytearray (n )
508
508
expect_le = expect_be [::- 1 ]
509
509
510
- self .assertEqual (expect_n , copybits (v , buffer , n , 0 ),
511
- f"PyLong_CopyBits (v, buffer, { n } , <big>)" )
510
+ self .assertEqual (expect_n , asnativebytes (v , buffer , n , 0 ),
511
+ f"PyLong_AsNativeBytes (v, buffer, { n } , <big>)" )
512
512
self .assertEqual (expect_be , buffer [:n ], "<big>" )
513
- self .assertEqual (expect_n , copybits (v , buffer , n , 1 ),
514
- f"PyLong_CopyBits (v, buffer, { n } , <little>)" )
513
+ self .assertEqual (expect_n , asnativebytes (v , buffer , n , 1 ),
514
+ f"PyLong_AsNativeBytes (v, buffer, { n } , <little>)" )
515
515
self .assertEqual (expect_le , buffer [:n ], "<little>" )
516
516
517
- def test_long_frombits (self ):
517
+ def test_long_fromnativebytes (self ):
518
518
import math
519
- from _testcapi import pylong_frombits as frombits , SIZE_MAX
519
+ from _testcapi import (
520
+ pylong_fromnativebytes as fromnativebytes ,
521
+ SIZE_MAX ,
522
+ )
520
523
521
524
# Abbreviate sizeof(Py_ssize_t) to SZ because we use it a lot
522
525
SZ = int (math .ceil (math .log (SIZE_MAX + 1 ) / math .log (2 )) / 8 )
@@ -534,14 +537,14 @@ def test_long_frombits(self):
534
537
n = len (v_be )
535
538
v_le = v_be [::- 1 ]
536
539
537
- self .assertEqual (expect_s , frombits (v_be , n , 0 , 1 ),
538
- f"PyLong_FromBits (buffer, { n } , <big>)" )
539
- self .assertEqual (expect_s , frombits (v_le , n , 1 , 1 ),
540
- f"PyLong_FromBits (buffer, { n } , <little>)" )
541
- self .assertEqual (expect_u , frombits (v_be , n , 0 , 0 ),
542
- f"PyLong_FromUnsignedBits (buffer, { n } , <big>)" )
543
- self .assertEqual (expect_u , frombits (v_le , n , 1 , 0 ),
544
- f"PyLong_FromUnsignedBits (buffer, { n } , <little>)" )
540
+ self .assertEqual (expect_s , fromnativebytes (v_be , n , 0 , 1 ),
541
+ f"PyLong_FromNativeBytes (buffer, { n } , <big>)" )
542
+ self .assertEqual (expect_s , fromnativebytes (v_le , n , 1 , 1 ),
543
+ f"PyLong_FromNativeBytes (buffer, { n } , <little>)" )
544
+ self .assertEqual (expect_u , fromnativebytes (v_be , n , 0 , 0 ),
545
+ f"PyLong_FromUnsignedNativeBytes (buffer, { n } , <big>)" )
546
+ self .assertEqual (expect_u , fromnativebytes (v_le , n , 1 , 0 ),
547
+ f"PyLong_FromUnsignedNativeBytes (buffer, { n } , <little>)" )
545
548
546
549
if __name__ == "__main__" :
547
550
unittest .main ()
0 commit comments