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 alanr
Recipients alanr
Date 2020-03-03.20:59:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583269142.54.0.23852633046.issue39841@roundup.psfhosted.org>
In-reply-to
Content
When an exception "as" variable occurs, it deletes local variables with the same name. This is certainly surprising, and doesn't appear to be a documented behavior (but maybe I don't know where to look). The word "bug" comes to mind.  The following few lines of code illustrate it nicely:

def testme():
    err = Exception("nothing worked")
    try:
        raise ValueError("no value")
    except ValueError as err:
        pass
    print(err)

testme()
History
Date User Action Args
2020-03-03 20:59:02alanrsetrecipients: + alanr
2020-03-03 20:59:02alanrsetmessageid: <1583269142.54.0.23852633046.issue39841@roundup.psfhosted.org>
2020-03-03 20:59:02alanrlinkissue39841 messages
2020-03-03 20:59:02alanrcreate