<br><br><div class="gmail_quote">On Mon, Jun 6, 2011 at 23:57, Georg Brandl <span dir="ltr">&lt;<a href="mailto:g.brandl@gmx.net">g.brandl@gmx.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 06/07/11 05:20, brett.cannon wrote:<br>
&gt; <a href="http://hg.python.org/cpython/rev/fc282e375703" target="_blank">http://hg.python.org/cpython/rev/fc282e375703</a><br>
&gt; changeset:   70695:fc282e375703<br>
&gt; user:        Brett Cannon &lt;<a href="mailto:brett@python.org">brett@python.org</a>&gt;<br>
&gt; date:        Mon Jun 06 20:20:36 2011 -0700<br>
&gt; summary:<br>
&gt;   Remove some extraneous parentheses and swap the comparison order to<br>
&gt; prevent accidental assignment.<br>
&gt;<br>
&gt; Silences a warning from LLVM/clang 2.9.<br>
<br>
</div>Swapping the comparison order here seems a bit inconsistent to me. There are<br>
lots of others around (e.g. &quot;len == 0&quot; in the patch context below). Why is<br>
this one so special?<br>
<br></blockquote><div><br></div><div>Old habit on how to do comparisons in C. Because C treats assignment as an expression it means comparisons can accidentally become an assignment if you accidentally leave out an = sign. By reversing this order it is simply not possible to have that silent bug and instead you would get a compiler error about trying to assign to a constant.</div>

<div><br></div><div>I&#39;ll revert that part of the change.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I think that another developer even got told off once for these kinds of<br>
comparisons.<br>
<br>
I hope the Clang warning is only about the parentheses.<br></blockquote><div><br></div><div>Yes, Clang only warned about the parentheses.</div><div><br></div><div>-Brett</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


<br>
Georg<br>
<div class="im"><br>
&gt; files:<br>
&gt;   Modules/arraymodule.c |  2 +-<br>
&gt;   1 files changed, 1 insertions(+), 1 deletions(-)<br>
&gt;<br>
&gt;<br>
&gt; diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c<br>
&gt; --- a/Modules/arraymodule.c<br>
&gt; +++ b/Modules/arraymodule.c<br>
&gt; @@ -2091,7 +2091,7 @@<br>
&gt;      if (len == 0) {<br>
&gt;          return PyUnicode_FromFormat(&quot;array(&#39;%c&#39;)&quot;, (int)typecode);<br>
&gt;      }<br>
&gt; -    if ((typecode == &#39;u&#39;))<br>
&gt; +    if (&#39;u&#39; == typecode)<br>
&gt;          v = array_tounicode(a, NULL);<br>
&gt;      else<br>
&gt;          v = array_tolist(a, NULL);<br>
<br>
<br>
<br>
</div>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/brett%40python.org" target="_blank">http://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</blockquote></div><br>