[ create a new paste ] login | about

Link: http://codepad.org/aMTYQgN5    [ raw code | output | fork ]

greg - Python, pasted on Jul 22:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# wrong line!

# this one works as expected
try:
    raise 'one'
except:
    pass

# this one prints the wrong line
try:
    exec("raise 'two'")
except:
    pass

# this one works as expected
exec("raise Exception('three')")


Output:
1
2
3
4
5
6
7
8
9
t.py:5: DeprecationWarning: raising a string exception is deprecated
  raise 'one'
t.py:1: DeprecationWarning: raising a string exception is deprecated
  # wrong line!
Traceback (most recent call last):
  Line 16, in <module>
    exec("raise Exception('three')")
  File "<string>", line 1, in <module>
Exception: three


Create a new paste based on this one


Comments: