# HG changeset patch # User Atul Varma # Date 1252308836 25200 # Node ID a78570a423ea5f6af554e256c69fb5c0130e12db # Parent 351525e95a4571fecb39c83cd3a0ca05f3f6050e Show code excerpts in js stack tracebacks diff -r 351525e95a45 -r a78570a423ea pydershell/pydershell.py --- a/pydershell/pydershell.py Sun Sep 06 14:59:58 2009 -0700 +++ b/pydershell/pydershell.py Mon Sep 07 00:33:56 2009 -0700 @@ -108,16 +108,22 @@ function = js_stack['function'] if script: frameinfo = dict(filename = script.filename, - lineno = js_stack['lineno'], - name = '') + lineno = js_stack['lineno'], + name = '') elif function and not function.is_python: frameinfo = dict(filename = function.filename, - lineno = js_stack['lineno'], - name = function.name) + lineno = js_stack['lineno'], + name = function.name) else: frameinfo = None if frameinfo: lines.insert(0, STACK_LINE % frameinfo) + try: + filelines = open(frameinfo['filename']).readlines() + line = filelines[frameinfo['lineno'] - 1].strip() + lines.insert(1, " %s" % line) + except Exception: + pass js_stack = js_stack['caller'] lines.insert(0, "Traceback (most recent call last):") return '\n'.join(lines)