[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-dev
Subject:    Re: [Python-Dev] Unbound locals in class scopes
From:       Ivan Levkivskyi <levkivskyi () gmail ! com>
Date:       2015-06-23 12:52:52
Message-ID: CAOMjWkn4y+Sf-KYRKPAsRTgMvBUFOvyi_xsr-yCZ9-6vTphnzQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 23 June 2015 at 05:33, Nick Coghlan <ncoghlan@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.

[Attachment #5 (text/html)]

<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 23 June \
2015 at 05:33, Nick Coghlan <span dir="ltr">&lt;<a href="mailto:ncoghlan@gmail.com" \
target="_blank">ncoghlan@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <span class=""><br>
&gt; Also, since classes inside functions are commonly used in unit tests (at<br>
&gt; least mine :-), I worry that *any* changes in this behavior might break<br>
&gt; working code (no matter how much that &quot;working&quot; could be considered \
an<br> &gt; accident, it&#39;s still going to be a bear to debug if this happens to \
you).<br> <br>
</span>Agreed - I think any change here would need to go through a<br>
deprecation period where we warned about cases where LOAD_NAME would<br>
be changed to LOAD_CLASSDEREF and there was a nonlocal defined with<br>
that name.<br>
<br>
Since it&#39;s trivial easy to workaround by renaming a local variable to<br>
use a name that differs from the nested class attribute, I&#39;d also be<br>
entirely happy with leaving the current behaviour as an obscure quirk<br>
- I&#39;m only +0 on changing it, and also +0 on declaring it &quot;not worth<br>
the hassle of changing&quot;.<br>
<br>
</blockquote></div><br></div><div class="gmail_extra">This is also my attitude on \
this issue. Looks like everyone agrees that this is<br></div><div \
class="gmail_extra">a strange behavior, but not strange enough to be \
changed.<br></div></div>



_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-marcsub-zyf4%40marc.info


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic