This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients martin.panter, r.david.murray
Date 2015-11-03.15:20:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1446564048.51.0.67716228615.issue25538@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-11-03 15:20:48r.david.murraysetrecipients: + r.david.murray, martin.panter
2015-11-03 15:20:48r.david.murraysetmessageid: <1446564048.51.0.67716228615.issue25538@psf.upfronthosting.co.za>
2015-11-03 15:20:48r.david.murraylinkissue25538 messages
2015-11-03 15:20:48r.david.murraycreate