@@ -448,18 +448,18 @@ def _classify_pyc(data, name, exc_details):
448
448
"""
449
449
magic = data [:4 ]
450
450
if magic != MAGIC_NUMBER :
451
- message = 'bad magic number in {!r}: {!r}' . format ( name , magic )
451
+ message = f 'bad magic number in { name !r} : { magic !r} '
452
452
_bootstrap ._verbose_message ('{}' , message )
453
453
raise ImportError (message , ** exc_details )
454
454
if len (data ) < 16 :
455
- message = 'reached EOF while reading pyc header of {!r}' . format ( name )
455
+ message = f 'reached EOF while reading pyc header of { name !r} '
456
456
_bootstrap ._verbose_message ('{}' , message )
457
457
raise EOFError (message )
458
458
flags = _r_long (data [4 :8 ])
459
459
# Only the first two flags are defined.
460
460
if flags & ~ 0b11 :
461
- raise ImportError ( 'invalid flags {!r} in {!r}' . format ( flags , name ),
462
- ** exc_details )
461
+ message = f 'invalid flags { flags !r} in { name !r} '
462
+ raise ImportError ( message , ** exc_details )
463
463
return flags
464
464
465
465
@@ -483,13 +483,12 @@ def _validate_timestamp_pyc(data, source_mtime, source_size, name,
483
483
484
484
"""
485
485
if _r_long (data [8 :12 ]) != (source_mtime & 0xFFFFFFFF ):
486
- message = 'bytecode is stale for {!r}' . format ( name )
486
+ message = f 'bytecode is stale for { name !r} '
487
487
_bootstrap ._verbose_message ('{}' , message )
488
488
raise ImportError (message , ** exc_details )
489
489
if (source_size is not None and
490
490
_r_long (data [12 :16 ]) != (source_size & 0xFFFFFFFF )):
491
- raise ImportError ('bytecode is stale for {!r}' .format (name ),
492
- ** exc_details )
491
+ raise ImportError (f'bytecode is stale for { name !r} ' , ** exc_details )
493
492
494
493
495
494
def _validate_hash_pyc (data , source_hash , name , exc_details ):
@@ -511,7 +510,7 @@ def _validate_hash_pyc(data, source_hash, name, exc_details):
511
510
"""
512
511
if data [8 :16 ] != source_hash :
513
512
raise ImportError (
514
- 'hash in bytecode doesn\' t match hash of source {!r}' . format ( name ) ,
513
+ f 'hash in bytecode doesn\' t match hash of source { name !r} ' ,
515
514
** exc_details ,
516
515
)
517
516
0 commit comments