[issue29593] Improve UnboundLocalError message for deleted names

Martin Panter report at bugs.python.org
Fri Feb 17 16:20:15 EST 2017


Martin Panter added the comment:

Matthias’s proposal sounds reasonable to me. There is a minor disadvantage that it will exceed the width of an 80-character terminal:

UnboundLocalError: local variable 'x' referenced before assignment, or got delet
ed

But I don’t think the wrapping is a big deal; it already happens with longer variable names anyway. I doubt using “unset” instead of “deleted” is any better. If you really wanted to make it clear, you would have to say “or got deleted, perhaps by an exception handler”, but that is probably going too far.

Another idea, which separates the hint from the technical error:

UnboundLocalError: local variable 'x' not set; perhaps it is not yet assigned

----------

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


More information about the Python-bugs-list mailing list