Message253997
What caught me out was more like this (but more complicated so it wasn't obvious the line mentioned wasn't part of the exception chain; in fact it looked like it was since it was a line that could very well have raised the exception in question):
rdmurray@pydev:~/python/p36>cat temp.py
def do_something():
try:
foo()
except Exception:
print('caught in do_something')
raise
def foo():
with cm():
print('all is well')
class cm:
def __enter__(self):
return self
def __exit__(*args, **kw):
raise Exception('exception in __exit__')
do_something()
rdmurray@pydev:~/python/p36>./python temp.py
all is well
caught in do_something
Traceback (most recent call last):
File "temp.py", line 20, in <module>
do_something()
File "temp.py", line 3, in do_something
foo()
File "temp.py", line 10, in foo
print('all is well')
File "temp.py", line 18, in __exit__
raise Exception('exception in __exit__')
Exception: exception in __exit__
The confusing line in the traceback is "print('all is well')", which obviously isn't raising the exception. |
|
Date |
User |
Action |
Args |
2015-11-03 15:20:48 | r.david.murray | set | recipients:
+ r.david.murray, martin.panter |
2015-11-03 15:20:48 | r.david.murray | set | messageid: <1446564048.51.0.67716228615.issue25538@psf.upfronthosting.co.za> |
2015-11-03 15:20:48 | r.david.murray | link | issue25538 messages |
2015-11-03 15:20:48 | r.david.murray | create | |
|