@@ -272,9 +272,18 @@ def test_exc(formatstr, args, exception, excmsg):
272272 #test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
273273 # "unsupported format character '?' (0x3000) at index 5")
274274 test_exc ('%d' , '1' , TypeError , "%d format: a number is required, not str" )
275+ test_exc ('%x' , '1' , TypeError , "%x format: a number is required, not str" )
276+ test_exc ('%x' , 3.14 , TypeError , "%x format: an integer is required, not float" )
275277 test_exc ('%g' , '1' , TypeError , "a float is required" )
276278 test_exc ('no format' , '1' , TypeError ,
277279 "not all arguments converted during string formatting" )
280+ test_exc ('%c' , - 1 , OverflowError , "%c arg not in range(0x110000)" )
281+ test_exc ('%c' , sys .maxunicode + 1 , OverflowError ,
282+ "%c arg not in range(0x110000)" )
283+ #test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)")
284+ test_exc ('%c' , 3.14 , TypeError , "%c requires int or char" )
285+ test_exc ('%c' , 'ab' , TypeError , "%c requires int or char" )
286+ test_exc ('%c' , b'x' , TypeError , "%c requires int or char" )
278287
279288 if maxsize == 2 ** 31 - 1 :
280289 # crashes 2.2.1 and earlier:
@@ -339,6 +348,8 @@ def test_exc(formatstr, args, exception, excmsg):
339348 "%d format: a number is required, not str" )
340349 test_exc (b'%d' , b'1' , TypeError ,
341350 "%d format: a number is required, not bytes" )
351+ test_exc (b'%x' , 3.14 , TypeError ,
352+ "%x format: an integer is required, not float" )
342353 test_exc (b'%g' , '1' , TypeError , "float argument required, not str" )
343354 test_exc (b'%g' , b'1' , TypeError , "float argument required, not bytes" )
344355 test_exc (b'no format' , 7 , TypeError ,
@@ -347,11 +358,17 @@ def test_exc(formatstr, args, exception, excmsg):
347358 "not all arguments converted during bytes formatting" )
348359 test_exc (b'no format' , bytearray (b'1' ), TypeError ,
349360 "not all arguments converted during bytes formatting" )
361+ test_exc (b"%c" , - 1 , TypeError ,
362+ "%c requires an integer in range(256) or a single byte" )
350363 test_exc (b"%c" , 256 , TypeError ,
351364 "%c requires an integer in range(256) or a single byte" )
365+ test_exc (b"%c" , 2 ** 128 , TypeError ,
366+ "%c requires an integer in range(256) or a single byte" )
352367 test_exc (b"%c" , b"Za" , TypeError ,
353368 "%c requires an integer in range(256) or a single byte" )
354- test_exc (b"%c" , "Yb" , TypeError ,
369+ test_exc (b"%c" , "Y" , TypeError ,
370+ "%c requires an integer in range(256) or a single byte" )
371+ test_exc (b"%c" , 3.14 , TypeError ,
355372 "%c requires an integer in range(256) or a single byte" )
356373 test_exc (b"%b" , "Xc" , TypeError ,
357374 "%b requires bytes, or an object that implements __bytes__, not 'str'" )
0 commit comments