File: test382.py

package info (click to toggle)
jython 2.5.3-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 43,404 kB
  • ctags: 105,521
  • sloc: python: 351,322; java: 216,346; xml: 1,547; sh: 330; perl: 124; ansic: 102; makefile: 101
file content (46 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
catching frame wasn't captured in a traceback
"""

import sys

def check(tb,expt_lines):
  assert tb.tb_frame is sys._getframe(1),"catching frame should be included"
  lines=[]
  while tb:
    lines.append(tb.tb_lineno)
    tb = tb.tb_next
  assert expt_lines==lines, "bogus line numbers: %s vs. expected %s" % (lines,expt_lines)

def f():
  try:
   raise KeyError # 17
  except:
    raise

try:
  f() # 22
except:
  t,e,tb = sys.exc_info()
  check(tb,[22,17])

try:
  f() # 28
except KeyError,e:
  t,e,tb = sys.exc_info()
  check(tb,[28,17])

try:
 1/0 # 34
except:
 t,e,tb = sys.exc_info()
 check(tb,[34])

try:
 try:
  1/0 # 41
 except:
  raise
except:
 t,e,tb = sys.exc_info()
 check(tb,[41])