Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af38f5a

Browse files
committed
Tweak at the suggestion of Ezio Melotti for exception messages when
EOF is hit while trying to read the header of a bytecode file.
1 parent 0b81111 commit af38f5a

3 files changed

Lines changed: 2307 additions & 2302 deletions

File tree

Lib/importlib/_bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,11 +668,11 @@ def _validate_bytecode_header(data, source_stats=None, name=None, path=None):
668668
_verbose_message(message)
669669
raise ImportError(message, **exc_details)
670670
elif len(raw_timestamp) != 4:
671-
message = 'incomplete timestamp in {!r}'.format(name)
671+
message = 'reached EOF while reading magic number in {!r}'.format(name)
672672
_verbose_message(message)
673673
raise EOFError(message)
674674
elif len(raw_size) != 4:
675-
message = 'incomplete size in {!r}'.format(name)
675+
message = 'reached EOF while reading size in {!r}'.format(name)
676676
_verbose_message(message)
677677
raise EOFError(message)
678678
if source_stats is not None:

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Tweak the exception message when the magic number or size value in a bytecode
14+
file is truncated.
15+
1316
- Issue #18065: Don't set __path__ to the package name for frozen packages.
1417

1518
- Issue #18088: When reloading a module, unconditionally reset all relevant

0 commit comments

Comments
 (0)