@@ -1322,17 +1322,22 @@ def equivalent_python(n, length, byteorder, signed=False):
13221322        check (tests4 , 'little' , signed = False )
13231323
13241324        self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = False )
1325-         self .assertRaises (OverflowError , (256 ).to_bytes , 1 , 'big' , signed = True )
13261325        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 )
13281330        self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'big' , signed = False )
13291331        self .assertRaises (OverflowError , (- 1 ).to_bytes , 2 , 'little' , signed = False )
13301332        self .assertEqual ((0 ).to_bytes (0 , 'big' ), b'' )
1333+         self .assertEqual ((0 ).to_bytes (0 , 'big' , signed = True ), b'' )
13311334        self .assertEqual ((1 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x01 ' )
13321335        self .assertEqual ((0 ).to_bytes (5 , 'big' ), b'\x00 \x00 \x00 \x00 \x00 ' )
13331336        self .assertEqual ((- 1 ).to_bytes (5 , 'big' , signed = True ),
13341337                         b'\xff \xff \xff \xff \xff ' )
13351338        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 )
13361341
13371342        # gh-98783 
13381343        class  SubStr (str ):
0 commit comments