Commits

Maciej Fijalkowski committed 0af571b

a bit more robust against IOErrors

  • Participants
  • Parent commits f8c7f89

Comments (0)

Files changed (1)

File _jitviewer/app.py

             source = CodeReprNoFile(loop)
         else:
             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:
+            try:
+                code = self.storage.load_code(loop.filename)[(loop.startlineno,
+                                                              loop.name)]
+                if code.co_name == '<module>' and code.co_firstlineno == 1:
                     with open(code.co_filename) as f:
                         source = CodeRepr(f.read(), code, loop)
-                except (IOError, OSError):
-                    source = CodeReprNoFile(loop)
-            else:
-                #try:
-                source = CodeRepr(inspect.getsource(code), code, loop)
-                #except:
-                #    source = CodeReprNoFile(loop)
+                else:
+                    source = CodeRepr(inspect.getsource(code), code, loop)
+            except (IOError, OSError):
+                source = CodeReprNoFile(loop)
         d = {'html': flask.render_template('loop.html',
                                            source=source,
                                            current_loop=name,