@@ -278,6 +278,8 @@ def test_common_format(self):
278278 "unsupported format %z at position 4" )
279279 test_exc_common ("abc %Id" , 1 , ValueError ,
280280 "unsupported format %I at position 4" )
281+ test_exc_common ("abc %'d" , 1 , ValueError ,
282+ "stray % at position 4 or unexpected format character \" '\" at position 5" )
281283 test_exc_common ("abc %1 d" , 1 , ValueError ,
282284 "stray % at position 4 or unexpected format character ' ' at position 6" )
283285 test_exc_common ('abc % (x)r' , {}, ValueError ,
@@ -312,12 +314,16 @@ def test_common_format(self):
312314 "not enough arguments for format string (got 0)" )
313315 test_exc_common ('%(x)r' , 1 , TypeError ,
314316 "format requires a mapping, not int" )
317+ test_exc_common ('%*r' , 1 , TypeError ,
318+ "not enough arguments for format string (got 1)" )
315319 test_exc_common ('%*r' , 3.14 , TypeError ,
316- "* requires int, not float " )
320+ "not enough arguments for format string (got 1) " )
317321 test_exc_common ('%*r' , (3.14 , 1 ), TypeError ,
318322 "format argument 1: * requires int, not float" )
323+ test_exc_common ('%.*r' , 1 , TypeError ,
324+ "not enough arguments for format string (got 1)" )
319325 test_exc_common ('%.*r' , 3.14 , TypeError ,
320- "* requires int, not float " )
326+ "not enough arguments for format string (got 1) " )
321327 test_exc_common ('%.*r' , (3.14 , 1 ), TypeError ,
322328 "format argument 1: * requires int, not float" )
323329 test_exc_common ('%*r' , (2 ** 1000 , 1 ), OverflowError ,
@@ -329,25 +335,25 @@ def test_common_format(self):
329335 test_exc_common ('%.*r' , (- 2 ** 1000 , 1 ), OverflowError ,
330336 "format argument 1: too big for precision" )
331337 test_exc_common ('%d' , '1' , TypeError ,
332- "a real number is required for format %d , not str" )
338+ "%d requires a real number, not str" )
333339 test_exc_common ('%d' , b'1' , TypeError ,
334- "a real number is required for format %d , not bytes" )
340+ "%d requires a real number, not bytes" )
335341 test_exc_common ('%d' , ('1' ,), TypeError ,
336- "format argument 1: a real number is required for format %d , not str" )
342+ "format argument 1: %d requires a real number, not str" )
337343 test_exc_common ('%x' , '1' , TypeError ,
338- "an integer is required for format %x , not str" )
344+ "%x requires an integer , not str" )
339345 test_exc_common ('%x' , 3.14 , TypeError ,
340- "an integer is required for format %x , not float" )
346+ "%x requires an integer , not float" )
341347 test_exc_common ('%x' , ('1' ,), TypeError ,
342- "format argument 1: an integer is required for format %x , not str" )
348+ "format argument 1: %x requires an integer , not str" )
343349 test_exc_common ('%i' , '1' , TypeError ,
344- "a real number is required for format %i , not str" )
350+ "%i requires a real number, not str" )
345351 test_exc_common ('%i' , b'1' , TypeError ,
346- "a real number is required for format %i , not bytes" )
352+ "%i requires a real number, not bytes" )
347353 test_exc_common ('%g' , '1' , TypeError ,
348- "a real number is required for format %g , not str" )
354+ "%g requires a real number, not str" )
349355 test_exc_common ('%g' , ('1' ,), TypeError ,
350- "format argument 1: a real number is required for format %g , not str" )
356+ "format argument 1: %g requires a real number, not str" )
351357
352358 def test_str_format (self ):
353359 testformat ("%r" , "\u0378 " , "'\\ u0378'" ) # non printable
@@ -361,8 +367,6 @@ def test_str_format(self):
361367 print ('Testing exceptions' )
362368 test_exc ('abc %b' , 1 , ValueError ,
363369 "unsupported format %b at position 4" )
364- test_exc ("abc %'d" , 1 , ValueError ,
365- "stray % at position 4 or unexpected format character ''' (U+0027) at position 5" )
366370 test_exc ("abc %\n d" , 1 , ValueError ,
367371 "stray % at position 4 or unexpected format character U+000A at position 5" )
368372 test_exc ("abc %\x1f d" , 1 , ValueError ,
@@ -386,11 +390,11 @@ def test_str_format(self):
386390 test_exc ('%(x).*r' , {'x' : 1 }, ValueError ,
387391 "* cannot be used with a parenthesised mapping key at position 0" )
388392 test_exc ('%(x)d' , {'x' : '1' }, TypeError ,
389- "format argument 'x': a real number is required for format %d , not str" )
393+ "format argument 'x': %d requires a real number, not str" )
390394 test_exc ('%(x)x' , {'x' : '1' }, TypeError ,
391- "format argument 'x': an integer is required for format %x , not str" )
395+ "format argument 'x': %x requires an integer , not str" )
392396 test_exc ('%(x)g' , {'x' : '1' }, TypeError ,
393- "format argument 'x': a real number is required for format %g , not str" )
397+ "format argument 'x': %g requires a real number, not str" )
394398 test_exc ('%c' , - 1 , OverflowError , "%c argument not in range(0x110000)" )
395399 test_exc ('%c' , (- 1 ,), OverflowError ,
396400 "format argument 1: %c argument not in range(0x110000)" )
@@ -465,8 +469,6 @@ def __bytes__(self):
465469 print ('Testing exceptions' )
466470 test_exc (b"abc %\n d" , 1 , ValueError ,
467471 "stray % at position 4 or unexpected format character with code 0x0a at position 5" )
468- test_exc (b"abc %'d" , 1 , ValueError ,
469- "stray % at position 4 or unexpected format character with code 0x27 at position 5" )
470472 test_exc (b"abc %\x1f d" , 1 , ValueError ,
471473 "stray % at position 4 or unexpected format character with code 0x1f at position 5" )
472474 test_exc (b"abc %\x7f d" , 1 , ValueError ,
@@ -488,11 +490,11 @@ def __bytes__(self):
488490 test_exc (b'%(x).*r' , {b'x' : 1 }, ValueError ,
489491 "* cannot be used with a parenthesised mapping key at position 0" )
490492 test_exc (b'%(x)d' , {b'x' : '1' }, TypeError ,
491- "format argument b'x': a real number is required for format %d , not str" )
493+ "format argument b'x': %d requires a real number, not str" )
492494 test_exc (b'%(x)x' , {b'x' : '1' }, TypeError ,
493- "format argument b'x': an integer is required for format %x , not str" )
495+ "format argument b'x': %x requires an integer , not str" )
494496 test_exc (b'%(x)g' , {b'x' : '1' }, TypeError ,
495- "format argument b'x': a real number is required for format %g , not str" )
497+ "format argument b'x': %g requires a real number, not str" )
496498 test_exc (b"%c" , - 1 , OverflowError ,
497499 "%c argument not in range(256)" )
498500 test_exc (b"%c" , (- 1 ,), OverflowError ,
0 commit comments