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 Garrett Berg
Recipients Garrett Berg
Date 2017-12-14.00:06:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1513209987.98.0.213398074469.issue32317@psf.upfronthosting.co.za>
In-reply-to
Content
I found a workaround, and probably the reason this has not been detected before:

    import sys

    def doclear2()
        try:
            1/0
        except ZeroDivisionError:
            sys.exc_clear()

    try:
        1/0
    except ZeroDivisionError:
        exc = sys.exc_info()[0]
        print("third exc (before doclear):", exc)
        doclear2()
        exc = sys.exc_info()[0]
        print("third exc (after  doclear):", exc)
        assert sys.exc_info()[0] is ZeroDivisionError

The above passes. It seems that being inside a local exception block allows for the spec to hold, only the "local exception" is cleared.

I still think this is a pretty major bug, but it is good to know what the workaround/reason it's "been working" is.
History
Date User Action Args
2017-12-14 00:06:28Garrett Bergsetrecipients: + Garrett Berg
2017-12-14 00:06:27Garrett Bergsetmessageid: <1513209987.98.0.213398074469.issue32317@psf.upfronthosting.co.za>
2017-12-14 00:06:27Garrett Berglinkissue32317 messages
2017-12-14 00:06:27Garrett Bergcreate