[issue40728] UnboundLocalError as a result of except statement variable re-assignment

Oleksandr Suvorov report at bugs.python.org
Fri May 22 07:19:17 EDT 2020


Oleksandr Suvorov <susliko at gmail.com> added the comment:

but if exc variable is only available in except block why then it shadows
the function variable name?

On Fri, May 22, 2020 at 1:15 PM Christian Heimes <report at bugs.python.org>
wrote:

>
> Christian Heimes <lists at cheimes.de> added the comment:
>
> UnboundLocalError is a subclass of NameError. You are getting a more
> specific error here.
>
> >>> UnboundLocalError.__mro__
> (<class 'UnboundLocalError'>, <class 'NameError'>, <class 'Exception'>,
> <class 'BaseException'>, <class 'object'>)
>
> ----------
> nosy: +christian.heimes
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue40728>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40728>
_______________________________________


More information about the Python-bugs-list mailing list