Commits

Maciej Fijalkowski  committed a243fd3

a silly workaround for module-global code

  • Participants
  • Parent commits b91ae3c

Comments (0)

Files changed (1)

File bin/jitviewer.py

             startline, endline = loop.linerange
             code = self.storage.load_code(loop.filename)[(loop.startlineno,
                                                           loop.name)]
-            source = CodeRepr(inspect.getsource(code), code, loop)
+            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,
                                            current_loop=no,