Antonio Cuni committed b374369

fix an obscure case in test_pypy_c: if by chance the JIT traces code in, the jitlogparser crashed because the co_firstlineno attribute is not accurate

Comments (0)

Files changed (1)


             return self.disassembled_codes[key]
         except KeyError:
-            res = dis(self.load_code(fname)[startlineno])
+            codeobjs = self.load_code(fname)
+            if startlineno not in codeobjs:
+                # cannot find the code obj at this line: this can happen for
+                # various reasons, e.g. because the .py files changed since
+                # the log was produced, or because the co_firstlineno
+                # attribute of the code object is wrong (e.g., code objects
+                # produced by gateway.applevel(), such as the ones found in
+                #
+                return None
+            code = codeobjs[startlineno]
+            res = dis(code)
             self.disassembled_codes[key] = res
             return res