[pypy-svn] pypy default: fix an obscure case in test_pypy_c: if by chance the JIT traces code in nanos.py, the jitlogparser crashed because the co_firstlineno attribute is not accurate
antocuni
commits-noreply at bitbucket.org
Mon Mar 14 10:38:44 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r42599:b37436954860
Date: 2011-03-14 10:38 +0100
http://bitbucket.org/pypy/pypy/changeset/b37436954860/
Log: fix an obscure case in test_pypy_c: if by chance the JIT traces code
in nanos.py, the jitlogparser crashed because the co_firstlineno
attribute is not accurate
diff --git a/pypy/tool/jitlogparser/storage.py b/pypy/tool/jitlogparser/storage.py
--- a/pypy/tool/jitlogparser/storage.py
+++ b/pypy/tool/jitlogparser/storage.py
@@ -37,7 +37,17 @@
try:
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
+ # nanos.py)
+ return None
+ code = codeobjs[startlineno]
+ res = dis(code)
self.disassembled_codes[key] = res
return res
More information about the Pypy-commit
mailing list