[Python-Dev] Unbound locals in class scopes

Ivan Levkivskyi levkivskyi at gmail.com
Tue Jun 23 14:52:52 CEST 2015

On 23 June 2015 at 05:33, Nick Coghlan <ncoghlan at gmail.com> wrote:

> > Also, since classes inside functions are commonly used in unit tests (at
> > least mine :-), I worry that *any* changes in this behavior might break
> > working code (no matter how much that "working" could be considered an
> > accident, it's still going to be a bear to debug if this happens to you).
> Agreed - I think any change here would need to go through a
> deprecation period where we warned about cases where LOAD_NAME would
> be changed to LOAD_CLASSDEREF and there was a nonlocal defined with
> that name.
> Since it's trivial easy to workaround by renaming a local variable to
> use a name that differs from the nested class attribute, I'd also be
> entirely happy with leaving the current behaviour as an obscure quirk
> - I'm only +0 on changing it, and also +0 on declaring it "not worth
> the hassle of changing".
This is also my attitude on this issue. Looks like everyone agrees that
this is
a strange behavior, but not strange enough to be changed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150623/789878e7/attachment.html>

More information about the Python-Dev mailing list