@@ -1322,17 +1322,22 @@ def equivalent_python(n, length, byteorder, signed=False):
1322
1322
check (tests4 , 'little' , signed = False )
1323
1323
1324
1324
self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = False )
1325
- self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = True )
1326
1325
self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'little' , signed = False )
1327
- self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'little' , signed = True )
1326
+ self .assertRaises (OverflowError , (128 ).to_bytes , 1 , 'big' , signed = True )
1327
+ self .assertRaises (OverflowError , (128 ).to_bytes , 1 , 'little' , signed = True )
1328
+ self .assertRaises (OverflowError , (- 129 ).to_bytes , 1 , 'big' , signed = True )
1329
+ self .assertRaises (OverflowError , (- 129 ).to_bytes , 1 , 'little' , signed = True )
1328
1330
self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'big' , signed = False )
1329
1331
self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'little' , signed = False )
1330
1332
self .assertEqual ((0 ).to_bytes (0 , 'big' ), b'' )
1333
+ self .assertEqual ((0 ).to_bytes (0 , 'big' , signed = True ), b'' )
1331
1334
self .assertEqual ((1 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x01 ' )
1332
1335
self .assertEqual ((0 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x00 ' )
1333
1336
self .assertEqual ((- 1 ).to_bytes (5 , 'big' , signed = True ),
1334
1337
b'\xff \xff \xff \xff \xff ' )
1335
1338
self .assertRaises (OverflowError , (1 ).to_bytes , 0 , 'big' )
1339
+ self .assertRaises (OverflowError , (- 1 ).to_bytes , 0 , 'big' , signed = True )
1340
+ self .assertRaises (OverflowError , (- 1 ).to_bytes , 0 , 'little' , signed = True )
1336
1341
1337
1342
# gh-98783
1338
1343
class SubStr (str ):
0 commit comments