From e10fd68f90453b96e832c7127520b2a32dc9aae7 Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Sun, 19 Jan 2014 14:07:00 -0300 Subject: [PATCH] fixed issue 1839: catch exception if source code cannot be opened in the debugger --- applications/admin/controllers/debug.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/admin/controllers/debug.py b/applications/admin/controllers/debug.py index a33c0f8b..c5f9bd4f 100644 --- a/applications/admin/controllers/debug.py +++ b/applications/admin/controllers/debug.py @@ -54,9 +54,13 @@ def interact(): filename = web_debugger.filename lineno = web_debugger.lineno if filename: + # prevent IOError 2 on some circuntances (EAFP instead of os.access) + try: + lines = open(filename).readlines() + except: + lines = "" lines = dict([(i + 1, l) for (i, l) in enumerate( - [l.strip("\n").strip("\r") for l - in open(filename).readlines()])]) + [l.strip("\n").strip("\r") for l in lines])]) filename = os.path.basename(filename) else: lines = {}