[pypy-commit] pypy default: if loading of .pyc file fails, just give up instead of exploding

fijal noreply at buildbot.pypy.org
Sun Aug 16 20:31:26 CEST 2015


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r78998:b92ab1013bf2
Date: 2015-08-16 20:31 +0200
http://bitbucket.org/pypy/pypy/changeset/b92ab1013bf2/

Log:	if loading of .pyc file fails, just give up instead of exploding

diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -308,7 +308,10 @@
         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


More information about the pypy-commit mailing list