<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Feb 8, 2016 at 9:44 AM Victor Stinner <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I changed the Python compiler to ignore any kind "constant<br>
expressions", whereas it only ignored strings and integers before:<br>
<a href="http://bugs.python.org/issue26204" rel="noreferrer" target="_blank">http://bugs.python.org/issue26204</a><br>
<br>
The compiler now also emits a SyntaxWarning on such case. IMHO the<br>
warning can help to detect bugs for developers who just learnt Python.<br>
<br>
The warning is *not* emited for strings, since triple quoted strings<br>
are a common syntax for multiline comments.<br>
<br>
The warning is *not* emited neither for ellispis (...) since "f():<br>
..." is a legit syntax for abstract function.<br>
<br>
Are you ok with the new warning?<br></blockquote><div><br></div><div>I'm +1 on this.</div><div><br></div><div>-gps</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
New behaviour:<br>
<br>
haypo@smithers$ ./python<br>
Python 3.6.0a0 (default:759a975e1230, Feb  8 2016, 18:21:23)<br>
>>> def f():<br>
...  False<br>
...<br>
<stdin>:2: SyntaxWarning: ignore constant statement<br>
<br>
>>> import dis; dis.dis(f)<br>
  2           0 LOAD_CONST               0 (None)<br>
              3 RETURN_VALUE<br>
<br>
<br>
Old behaviour:<br>
<br>
haypo@smithers$ python3<br>
Python 3.4.3 (default, Jun 29 2015, 12:16:01)<br>
>>> def f():<br>
...  False<br>
...<br>
>>> import dis; dis.dis(f)<br>
  2           0 LOAD_CONST               1 (False)<br>
              3 POP_TOP<br>
              4 LOAD_CONST               0 (None)<br>
              7 RETURN_VALUE<br>
<br>
<br>
<br>
Before strings and numbers were already ignored. Example:<br>
<br>
haypo@smithers$ python3<br>
Python 3.4.3 (default, Jun 29 2015, 12:16:01)<br>
<br>
>>> def f():<br>
...  123<br>
...<br>
>>> import dis; dis.dis(f)<br>
  2           0 LOAD_CONST               0 (None)<br>
              3 RETURN_VALUE<br>
<br>
<br>
Victor<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/greg%40krypto.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/greg%40krypto.org</a><br>
</blockquote></div></div>