summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-02-25 16:33:39 (GMT)
committerGuido van Rossum <guido@python.org>1998-02-25 16:33:39 (GMT)
commit7266496b0043fa77375ebf31aceeff829aed8b80 (patch)
tree091800869458e5e800aec0a5c79dd36212c50be6 /Lib
parent50b3eb6a9ef770172c292c24952f766621b50af5 (diff)
downloadcpython-7266496b0043fa77375ebf31aceeff829aed8b80.zip
cpython-7266496b0043fa77375ebf31aceeff829aed8b80.tar.gz
cpython-7266496b0043fa77375ebf31aceeff829aed8b80.tar.bz2
Tweak the tb_lineno() function to be compatible with JPython, which
has no line number table etc.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/traceback.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py
index d508e03..d579639 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -188,10 +188,14 @@ def extract_stack(f=None, limit = None):
# in compile.c.
def tb_lineno(tb):
- c = tb.tb_frame.f_code
- tab = c.co_lnotab
- line = c.co_firstlineno
- stopat = tb.tb_lasti
+ f = tb.tb_frame
+ try:
+ c = f.f_code
+ tab = c.co_lnotab
+ line = c.co_firstlineno
+ stopat = tb.tb_lasti
+ except AttributeError:
+ return f.f_lineno
addr = 0
for i in range(0, len(tab), 2):
addr = addr + ord(tab[i])