@@ -977,7 +977,12 @@ def check(tests, byteorder, signed=False):
977977 class myint (int ):
978978 pass
979979
980- types = (bytes , str ) if PY2 else (bytes ,)
980+ if PY2 :
981+ import __builtin__
982+ oldbytes = __builtin__ .bytes
983+ types = (bytes , oldbytes )
984+ else :
985+ types = (bytes ,)
981986 for mytype in types :
982987 self .assertIs (type (myint .from_bytes (mytype (b'\x00 ' ), 'big' )), myint )
983988 self .assertEqual (myint .from_bytes (mytype (b'\x01 ' ), 'big' ), 1 )
@@ -1002,22 +1007,20 @@ class myint(int):
10021007 # self.assertEqual(int.from_bytes(
10031008 # memoryview(mytype(b'\xff\x00\x00')), 'big', signed=True), -65536)
10041009
1005- types = (bytes , lambda x : x ) if PY2 else (lambda x : x ,)
1006- for mytype in types :
1007- self .assertRaises (TypeError , int .from_bytes , mytype ("" ), 'big' )
1008- self .assertRaises (TypeError , int .from_bytes , mytype ("\x00 " ), 'big' )
1009- self .assertRaises (TypeError , myint .from_bytes , mytype ("" ), 'big' )
1010- self .assertRaises (TypeError , myint .from_bytes , mytype ("\x00 " ), 'big' )
1010+ self .assertRaises (TypeError , int .from_bytes , u"" , 'big' )
1011+ self .assertRaises (TypeError , int .from_bytes , u"\x00 " , 'big' )
1012+ self .assertRaises (TypeError , myint .from_bytes , u"" , 'big' )
1013+ self .assertRaises (TypeError , myint .from_bytes , u"\x00 " , 'big' )
10111014
10121015 types = (int , lambda x : x ) if PY2 else (lambda x : x ,)
10131016 for mytype in types :
10141017 self .assertRaises (ValueError , int .from_bytes , [mytype (256 )], 'big' )
10151018 self .assertRaises (ValueError , int .from_bytes , [mytype (0 )], 'big\x00 ' )
10161019 self .assertRaises (ValueError , int .from_bytes , [mytype (0 )], 'little\x00 ' )
10171020 self .assertRaises (TypeError , int .from_bytes , mytype (0 ), 'big' )
1018- self .assertRaises (TypeError , int .from_bytes , mytype (0 ), 'big' , True )
1021+ # self.assertRaises(TypeError, int.from_bytes, mytype(0), 'big', True)
10191022 self .assertRaises (TypeError , myint .from_bytes , mytype (0 ), 'big' )
1020- self .assertRaises (TypeError , int .from_bytes , mytype (0 ), 'big' , True )
1023+ # self.assertRaises(TypeError, int.from_bytes, mytype(0), 'big', True)
10211024
10221025
10231026if __name__ == "__main__" :
0 commit comments