[issue26237] UnboundLocalError error while handling exception

Марк Коренберг report at bugs.python.org
Fri Jan 29 04:40:26 EST 2016


New submission from Марк Коренберг:

This works right in Python 2.7, but fails in python3:

UnboundLocalError: local variable 'e' referenced before assignment


def test():
    try:
        raise Exception('a')
    except Exception as e:
        pass
    else:
        return
    print(e)

test()

----------
messages: 259201
nosy: mmarkk
priority: normal
severity: normal
status: open
title: UnboundLocalError error while handling exception
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26237>
_______________________________________


More information about the Python-bugs-list mailing list