@@ -1374,17 +1374,22 @@ def equivalent_python(n, length, byteorder, signed=False):
13741374 check (tests4 , 'little' , signed = False )
13751375
13761376 self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = False )
1377- self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = True )
13781377 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 )
13801382 self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'big' , signed = False )
13811383 self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'little' , signed = False )
13821384 self .assertEqual ((0 ).to_bytes (0 , 'big' ), b'' )
1385+ self .assertEqual ((0 ).to_bytes (0 , 'big' , signed = True ), b'' )
13831386 self .assertEqual ((1 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x01 ' )
13841387 self .assertEqual ((0 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x00 ' )
13851388 self .assertEqual ((- 1 ).to_bytes (5 , 'big' , signed = True ),
13861389 b'\xff \xff \xff \xff \xff ' )
13871390 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 )
13881393
13891394 # gh-98783
13901395 class SubStr (str ):
0 commit comments