[pypy-commit] jitviewer default: a silly workaround for module-global code

fijal noreply at buildbot.pypy.org
Sun Jul 24 22:38:41 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r163:a243fd3d0a1e
Date: 2011-07-24 22:38 +0200
http://bitbucket.org/pypy/jitviewer/changeset/a243fd3d0a1e/

Log:	a silly workaround for module-global code

diff --git a/bin/jitviewer.py b/bin/jitviewer.py
--- a/bin/jitviewer.py
+++ b/bin/jitviewer.py
@@ -130,6 +130,13 @@
             startline, endline = loop.linerange
             code = self.storage.load_code(loop.filename)[(loop.startlineno,
                                                           loop.name)]
+            if code.co_name == '<module>' and code.co_firstlineno == 1:
+                try:
+                    with open(code.co_filename) as f:
+                        source = CodeRepr(f.read(), code, loop)
+                except (IOError, OSError):
+                    source = CodeReprNoFile(loop)
+            else:
             source = CodeRepr(inspect.getsource(code), code, loop)
         d = {'html': flask.render_template('loop.html',
                                            source=source,


More information about the pypy-commit mailing list