[New-bugs-announce] [issue29593] Improve UnboundLocalError message for deleted names

Matthias Bussonnier report at bugs.python.org
Fri Feb 17 12:06:57 EST 2017


New submission from Matthias Bussonnier:

Raymond Hettinger reported during PyCon Canada 2016 Keynote (~20m30 sec)
that unbound local error message was inaccurate, it state that :

> local variable 'xxx' referenced before assignment

Though it can be assigned and deleted.

    for a toy example:

       def foo():
          x = 1
          del x
          print(x)

       foo()

Do the same for free variable.

    def multiplier(n):
	def multiply(x):
	    return x * n
	del n
	return multiply

The error message can be improved by adding "or got deleted".

----------
messages: 288023
nosy: mbussonn
priority: normal
pull_requests: 102
severity: normal
status: open
title: Improve UnboundLocalError message for deleted names
type: enhancement
versions: Python 3.7

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


More information about the New-bugs-announce mailing list