From d55470f753222e85b3a1b2aea250002582182acd Mon Sep 17 00:00:00 2001 From: Mariano Reingart Date: Tue, 24 Sep 2013 02:52:01 -0300 Subject: [PATCH] fixed line not found issues in set breakpoint (linecache patch, used by the debugger) --- gluon/widget.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gluon/widget.py b/gluon/widget.py index 3f2b1fd1..be222580 100644 --- a/gluon/widget.py +++ b/gluon/widget.py @@ -1263,6 +1263,25 @@ end tell print '\t', url print 'use "kill -SIGTERM %i" to shutdown the web2py server' % os.getpid() + # enhance linecache.getline (used by debugger) to look at the source file + # if the line was not found (under py2exe & when file was modified) + import linecache + py2exe_getline = linecache.getline + def getline(filename, lineno, *args, **kwargs): + line = py2exe_getline(filename, lineno, *args, **kwargs) + if not line: + f = open(filename, "r") + try: + for i, line in enumerate(f): + if lineno == i + 1: + break + else: + line = None + finally: + f.close() + return line + linecache.getline = getline + server = main.HttpServer(ip=ip, port=port, password=options.password,