Skip to content

Commit 09cbb9d

Browse files
committed
fstring the works
1 parent ce3ab9e commit 09cbb9d

File tree

2 files changed

+1943
-1945
lines changed

2 files changed

+1943
-1945
lines changed

Lib/importlib/_bootstrap_external.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,18 +448,18 @@ def _classify_pyc(data, name, exc_details):
448448
"""
449449
magic = data[:4]
450450
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}'
452452
_bootstrap._verbose_message('{}', message)
453453
raise ImportError(message, **exc_details)
454454
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}'
456456
_bootstrap._verbose_message('{}', message)
457457
raise EOFError(message)
458458
flags = _r_long(data[4:8])
459459
# Only the first two flags are defined.
460460
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)
463463
return flags
464464

465465

@@ -483,13 +483,12 @@ def _validate_timestamp_pyc(data, source_mtime, source_size, name,
483483
484484
"""
485485
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}'
487487
_bootstrap._verbose_message('{}', message)
488488
raise ImportError(message, **exc_details)
489489
if (source_size is not None and
490490
_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)
493492

494493

495494
def _validate_hash_pyc(data, source_hash, name, exc_details):
@@ -511,7 +510,7 @@ def _validate_hash_pyc(data, source_hash, name, exc_details):
511510
"""
512511
if data[8:16] != source_hash:
513512
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}',
515514
**exc_details,
516515
)
517516

0 commit comments

Comments
 (0)