@@ -1374,17 +1374,22 @@ def equivalent_python(n, length, byteorder, signed=False):
1374
1374
check (tests4 , 'little' , signed = False )
1375
1375
1376
1376
self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = False )
1377
- self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = True )
1378
1377
self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'little' , signed = False )
1379
- self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'little' , signed = True )
1378
+ self .assertRaises (OverflowError , (128 ).to_bytes , 1 , 'big' , signed = True )
1379
+ self .assertRaises (OverflowError , (128 ).to_bytes , 1 , 'little' , signed = True )
1380
+ self .assertRaises (OverflowError , (- 129 ).to_bytes , 1 , 'big' , signed = True )
1381
+ self .assertRaises (OverflowError , (- 129 ).to_bytes , 1 , 'little' , signed = True )
1380
1382
self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'big' , signed = False )
1381
1383
self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'little' , signed = False )
1382
1384
self .assertEqual ((0 ).to_bytes (0 , 'big' ), b'' )
1385
+ self .assertEqual ((0 ).to_bytes (0 , 'big' , signed = True ), b'' )
1383
1386
self .assertEqual ((1 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x01 ' )
1384
1387
self .assertEqual ((0 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x00 ' )
1385
1388
self .assertEqual ((- 1 ).to_bytes (5 , 'big' , signed = True ),
1386
1389
b'\xff \xff \xff \xff \xff ' )
1387
1390
self .assertRaises (OverflowError , (1 ).to_bytes , 0 , 'big' )
1391
+ self .assertRaises (OverflowError , (- 1 ).to_bytes , 0 , 'big' , signed = True )
1392
+ self .assertRaises (OverflowError , (- 1 ).to_bytes , 0 , 'little' , signed = True )
1388
1393
1389
1394
# gh-98783
1390
1395
class SubStr (str ):
0 commit comments