[Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement

Guido van Rossum guido at python.org
Mon Feb 8 15:34:22 EST 2016


On Mon, Feb 8, 2016 at 11:51 AM, Victor Stinner
<victor.stinner at gmail.com> wrote:
> Le 8 févr. 2016 8:14 PM, "Guido van Rossum" <guido at python.org> a écrit :
>> Hum. I'm not excited by this idea. It is not bad syntax.
>
> Do you see an use case for "constant statements" other than strings and
> ellipsis?

The same use case as for all dead code: it could be a placeholder for
something better in the future.

It could also be generated code where the generator expects the
optimizer to remove it (or doesn't care).

If you want to do linter integration that should probably be
integrated with the user's editor, like it is in PyCharm, and IIUC
people can do this in e.g. Emacs, Sublime or Vim as well. Leave the
interpreter alone.

> Such statement does nothing. Previously the compiler emited
> LOAD_CONST+POP_TOP.
>
> GCC also emits a warning on such code.
>
>> Have you
>> actually seen newbies who were confused by such things?
>
> Well, not really. But I don't see any use case of such code except of
> obvious mistakes. Sometimes such code appears after multiple refactoring
> (and mistakes).
>
> Are you suggesting to remove the warning?

I haven't seen this warning yet. I take it this is new in the 3.6 branch?

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list