A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20060607/d79597bd/attachment.html below:

<br>I just submitted <a href="http://python.org/sf/1501934">http://python.org/sf/1501934</a> and assigned it to Neal so it doesn't get forgotten before 2.5 goes out ;) It seems Python 2.5 compiles the following code incorrectly:
<br><br>&gt;&gt;&gt; g = 1<br>&gt;&gt;&gt; def f1():<br>...&nbsp;&nbsp;&nbsp;&nbsp; g += 1<br>... <br>&gt;&gt;&gt; f1()<br>&gt;&gt;&gt; g<br>2<br><br>It looks like the compiler is not seeing augmented assignment as creating a local name, as this fails properly:
<br><br clear="all">&gt;&gt;&gt; def f2():<br>...&nbsp;&nbsp;&nbsp;&nbsp; g += 1<br>...&nbsp;&nbsp;&nbsp;&nbsp; g = 5<br>... <br>&gt;&gt;&gt; f2()<br>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>&nbsp; File &quot;&lt;stdin&gt;&quot;, line 2, in f2
<br>UnboundLocalError: local variable 'g' referenced before assignment<br><br>The dis.dis output confirms this:<br>&gt;&gt;&gt; dis.dis(f1)<br>&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 LOAD_GLOBAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 (g)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 LOAD_CONST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 (1)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6 INPLACE_ADD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7 STORE_GLOBAL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 (g)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10 LOAD_CONST&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 (None)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 RETURN_VALUE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>If anyone feels like fixing it and happens to remember where the new compiler does the fast-locals optimization (I recall a few people were working on extra optimizations and all), please do :-) (I can probably look at it before 
2.5 if no one else does, though.) It may be a good idea to check for more such cornercases while we're at it (but I couldn't find any in the fast-locals bit.)<br><br>-- <br>Thomas Wouters &lt;<a href="mailto:thomas@python.org">
thomas@python.org</a>&gt;<br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4