diff options
author | Maciej Fijalkowski <fijall@gmail.com> | 2015-08-16 20:31:29 +0200 |
---|---|---|
committer | Maciej Fijalkowski <fijall@gmail.com> | 2015-08-16 20:31:29 +0200 |
commit | cfe5470cc7a9ce2e2bf419803d84be0ec67a647e (patch) | |
tree | 1b1eb808b98e6d47e6795bf43cd66e5252a42cc8 /_pytest | |
parent | only manipulate udir, sys.path if __main__ (diff) | |
download | pypy-cfe5470cc7a9ce2e2bf419803d84be0ec67a647e.tar.gz pypy-cfe5470cc7a9ce2e2bf419803d84be0ec67a647e.tar.bz2 pypy-cfe5470cc7a9ce2e2bf419803d84be0ec67a647e.zip |
if loading of .pyc file fails, just give up instead of exploding
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/assertion/rewrite.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index 95bf4117df..f31121f5d2 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -308,7 +308,10 @@ def _read_pyc(source, pyc): if (len(data) != 8 or data[:4] != imp.get_magic() or struct.unpack("<l", data[4:])[0] != mtime): return None - co = marshal.load(fp) + try: + co = marshal.load(fp) + except ValueError: + return None # e.g. bad marshal data because of pypy/cpython mix if not isinstance(co, types.CodeType): # That's interesting.... return None |