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

2016-02-09 Thread Joseph Martinot-Lagarde
Victor Stinner gmail.com> writes: > > Hi, > > I changed the Python compiler to ignore any kind "constant > expressions", whereas it only ignored strings and integers before: > http://bugs.python.org/issue26204 > > The compiler now also emits a SyntaxWarning on such case. IMHO the > warning

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

2016-02-09 Thread Victor Stinner
2016-02-09 10:57 GMT+01:00 Joseph Martinot-Lagarde : > I frequently use 1/0 as a quick break in a script or a program (it's even > more useful with post-mortem debugging). Would it be considered as a > constant and ignored instead of raising a ZeroDivisionError ? "self.x -

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

2016-02-09 Thread Georg Brandl
On 02/09/2016 10:57 AM, Joseph Martinot-Lagarde wrote: > Victor Stinner gmail.com> writes: > >> >> Hi, >> >> I changed the Python compiler to ignore any kind "constant >> expressions", whereas it only ignored strings and integers before: >> http://bugs.python.org/issue26204 >> >> The compiler

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

2016-02-09 Thread Michel Desmoulin
Hello, Le 08/02/2016 20:13, Guido van Rossum a écrit : On Mon, Feb 8, 2016 at 9:44 AM, Victor Stinner wrote: I changed the Python compiler to ignore any kind "constant expressions", whereas it only ignored strings and integers before:

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

2016-02-09 Thread Andrew Barnert via Python-Dev
On Tuesday, February 9, 2016 8:14 AM, Michel Desmoulin wrote: > I give regular Python trainings and I see similar errors regularly such as: > > - not returning something; > - using something without putting the result back in a variable. > > However, these are

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

2016-02-09 Thread Yury Selivanov
On 2016-02-08 8:02 PM, Steven D'Aprano wrote: On Mon, Feb 08, 2016 at 05:43:25PM -0500, Yury Selivanov wrote: On 2016-02-08 5:19 PM, Terry Reedy wrote: On 2/8/2016 4:51 PM, Victor Stinner wrote: 2016-02-08 22:28 GMT+01:00 Alexander Walters : What incantation do

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

2016-02-08 Thread John Mark Vandenberg
On Tue, Feb 9, 2016 at 7:34 AM, Guido van Rossum wrote: > On Mon, Feb 8, 2016 at 11:51 AM, Victor Stinner > wrote: >> Le 8 févr. 2016 8:14 PM, "Guido van Rossum" a écrit : >>> Hum. I'm not excited by this idea. It is not bad syntax.

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

2016-02-08 Thread Chris Angelico
On Tue, Feb 9, 2016 at 12:41 PM, MRAB wrote: > On 2016-02-09 00:53, Guido van Rossum wrote: >> >> The warning for 'assert (cond, msg)' was specifically put in because >> this is a nasty trap. It's *always* a mistaken attempt to write >> 'assert cond, msg' -- usually in

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

2016-02-08 Thread Guido van Rossum
On Mon, Feb 8, 2016 at 5:41 PM, MRAB wrote: > On 2016-02-09 00:53, Guido van Rossum wrote: >> >> The warning for 'assert (cond, msg)' was specifically put in because >> this is a nasty trap. It's *always* a mistaken attempt to write >> 'assert cond, msg' -- usually in

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

2016-02-08 Thread MRAB
On 2016-02-09 00:53, Guido van Rossum wrote: The warning for 'assert (cond, msg)' was specifically put in because this is a nasty trap. It's *always* a mistaken attempt to write 'assert cond, msg' -- usually in an attempt to break a long line without using a backslash. I'd actually consider

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

2016-02-08 Thread Guido van Rossum
Personally I don't think it's worth the churn. On Mon, Feb 8, 2016 at 5:49 PM, Chris Angelico wrote: > On Tue, Feb 9, 2016 at 12:41 PM, MRAB wrote: >> On 2016-02-09 00:53, Guido van Rossum wrote: >>> >>> The warning for 'assert (cond, msg)' was

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

2016-02-08 Thread xiscu
>> New behaviour: >> >> haypo@smithers$ ./python >> Python 3.6.0a0 (default:759a975e1230, Feb 8 2016, 18:21:23) > def f(): >> ... False >> ... Ok, I see in your case there's no return :-) ___ Python-Dev mailing list Python-Dev@python.org

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

2016-02-08 Thread francismb
Hi, On 02/08/2016 06:44 PM, Victor Stinner wrote: > Hi, > > I changed the Python compiler to ignore any kind "constant > expressions", whereas it only ignored strings and integers before: > http://bugs.python.org/issue26204 > > The compiler now also emits a SyntaxWarning on such case. IMHO the

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

2016-02-08 Thread Ethan Furman
On 02/08/2016 10:00 AM, francismb wrote: > On 02/08/2016 06:44 PM, Victor Stinner wrote: >> I changed the Python compiler to ignore any kind "constant >> expressions", whereas it only ignored strings and integers before: >> http://bugs.python.org/issue26204 >> >> The compiler now also emits a

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

2016-02-08 Thread Victor Stinner
Hi, I changed the Python compiler to ignore any kind "constant expressions", whereas it only ignored strings and integers before: http://bugs.python.org/issue26204 The compiler now also emits a SyntaxWarning on such case. IMHO the warning can help to detect bugs for developers who just learnt

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

2016-02-08 Thread Ethan Furman
On 02/08/2016 09:44 AM, Victor Stinner wrote: > Are you ok with the new warning? +1 -- ~Ethan~ ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

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

2016-02-08 Thread Gregory P. Smith
On Mon, Feb 8, 2016 at 9:44 AM Victor Stinner wrote: > Hi, > > I changed the Python compiler to ignore any kind "constant > expressions", whereas it only ignored strings and integers before: > http://bugs.python.org/issue26204 > > The compiler now also emits a

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

2016-02-08 Thread Guido van Rossum
On Mon, Feb 8, 2016 at 11:51 AM, Victor Stinner wrote: > Le 8 févr. 2016 8:14 PM, "Guido van Rossum" 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 >

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

2016-02-08 Thread John Mark Vandenberg
On Tue, Feb 9, 2016 at 8:20 AM, Victor Stinner wrote: > Le 8 févr. 2016 9:34 PM, "Guido van Rossum" a écrit : >> If you want to do linter integration that should probably be >> integrated with the user's editor, like it is in PyCharm, and IIUC >>

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

2016-02-08 Thread Ethan Furman
On 02/08/2016 10:15 AM, Ethan Furman wrote: On 02/08/2016 09:44 AM, Victor Stinner wrote: > Are you ok with the new warning? +1 Changing my vote: -1 on the warning +0 on simply removing the unused constant -- ~Ethan~ ___ Python-Dev mailing list

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

2016-02-08 Thread Victor Stinner
Le 8 févr. 2016 9:10 PM, "Alexander Walters" a écrit : > > I am not keen on a SyntaxWarning. Either something is python syntax, or it is not. Oh I forgot to mention that Python already emits SyntaxWarning, on "assert True" for example. Victor

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

2016-02-08 Thread Guido van Rossum
On Mon, Feb 8, 2016 at 9:44 AM, Victor Stinner wrote: > I changed the Python compiler to ignore any kind "constant > expressions", whereas it only ignored strings and integers before: > http://bugs.python.org/issue26204 > > The compiler now also emits a SyntaxWarning on

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

2016-02-08 Thread Andrew Barnert via Python-Dev
> On Feb 8, 2016, at 11:13, Guido van Rossum wrote: > >> On Mon, Feb 8, 2016 at 9:44 AM, Victor Stinner >> wrote: >> I changed the Python compiler to ignore any kind "constant >> expressions", whereas it only ignored strings and integers before: >>

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

2016-02-08 Thread Victor Stinner
Le 8 févr. 2016 9:34 PM, "Guido van Rossum" a écrit : > 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.

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

2016-02-08 Thread Guido van Rossum
On Mon, Feb 8, 2016 at 1:20 PM, Victor Stinner wrote: > Le 8 févr. 2016 9:34 PM, "Guido van Rossum" a écrit : >> If you want to do linter integration that should probably be >> integrated with the user's editor, like it is in PyCharm, and IIUC >>

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

2016-02-08 Thread Alexander Walters
What incantation do you need to do to make that behavior apparent? tritium@gesa:~$ python3.5 -W all Python 3.5.1 (default, Dec 18 2015, 02:15:10) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. Jedi is not installed, falling back to readline >>> assert

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

2016-02-08 Thread John Mark Vandenberg
On Tue, Feb 9, 2016 at 8:41 AM, Alexander Walters wrote: > > > On 2/8/2016 16:37, John Mark Vandenberg wrote: >> >> fwiw, pyflakes doesnt detect this. I've created a bug for that >> https://bugs.launchpad.net/pyflakes/+bug/1543246 > > > Flake8 does, so it might be in the

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

2016-02-08 Thread Alexander Walters
On 2/8/2016 16:37, John Mark Vandenberg wrote: fwiw, pyflakes doesnt detect this. I've created a bug for that https://bugs.launchpad.net/pyflakes/+bug/1543246 Flake8 does, so it might be in the ... poorly named ... pep8 checker. ___ Python-Dev

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

2016-02-08 Thread Victor Stinner
Le 8 févr. 2016 8:14 PM, "Guido van Rossum" 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? Such statement does nothing. Previously the compiler emited LOAD_CONST+POP_TOP.

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

2016-02-08 Thread Alexander Walters
I am not keen on a SyntaxWarning. Either something is python syntax, or it is not. This warning catches something linters have been catching for ages. I really don't see the value in adding this, and can see it causing more confusion than it solves. In the #python irc channel, we see quite

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

2016-02-08 Thread Yury Selivanov
On 2016-02-08 5:19 PM, Terry Reedy wrote: On 2/8/2016 4:51 PM, Victor Stinner wrote: 2016-02-08 22:28 GMT+01:00 Alexander Walters : What incantation do you need to do to make that behavior apparent? I didn't know. I just checked. It's assert used with a non-empty

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

2016-02-08 Thread John Mark Vandenberg
On Tue, Feb 9, 2016 at 8:51 AM, Victor Stinner wrote: > 2016-02-08 22:28 GMT+01:00 Alexander Walters : >> What incantation do you need to do to make that behavior apparent? > > I didn't know. I just checked. It's assert used with a non-empty

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

2016-02-08 Thread Terry Reedy
On 2/8/2016 4:51 PM, Victor Stinner wrote: 2016-02-08 22:28 GMT+01:00 Alexander Walters : What incantation do you need to do to make that behavior apparent? I didn't know. I just checked. It's assert used with a non-empty tuple: assert ("tuple",) :1: SyntaxWarning:

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

2016-02-08 Thread Victor Stinner
2016-02-08 22:28 GMT+01:00 Alexander Walters : > What incantation do you need to do to make that behavior apparent? I didn't know. I just checked. It's assert used with a non-empty tuple: >>> assert ("tuple",) :1: SyntaxWarning: assertion is always true, perhaps remove

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

2016-02-08 Thread Chris Barker
On Mon, Feb 8, 2016 at 3:48 PM, MRAB wrote: > help('assert') > > You'll see that in "assert (True,)", the tuple (an object) is the first > condition (and probably a mistake), whereas in "assert True,", the True is > the condition and the second expression (after

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

2016-02-08 Thread MRAB
On 2016-02-08 23:21, Chris Barker wrote: On Mon, Feb 8, 2016 at 1:51 PM, Victor Stinner > wrote: I didn't know. I just checked. It's assert used with a non-empty tuple: >>> assert ("tuple",) which is more interesting with a

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

2016-02-08 Thread Chris Barker
On Mon, Feb 8, 2016 at 1:51 PM, Victor Stinner wrote: > I didn't know. I just checked. It's assert used with a non-empty tuple: > > >>> assert ("tuple",) > which is more interesting with a tuple without the parentheses: t = In [*4*]: t = True, In [*5*]: t Out[*5*]:

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

2016-02-08 Thread Guido van Rossum
The warning for 'assert (cond, msg)' was specifically put in because this is a nasty trap. It's *always* a mistaken attempt to write 'assert cond, msg' -- usually in an attempt to break a long line without using a backslash. I'd actually consider promoting it to a syntax error rather than removing

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

2016-02-08 Thread Steven D'Aprano
On Mon, Feb 08, 2016 at 05:43:25PM -0500, Yury Selivanov wrote: > > > On 2016-02-08 5:19 PM, Terry Reedy wrote: > >On 2/8/2016 4:51 PM, Victor Stinner wrote: > >>2016-02-08 22:28 GMT+01:00 Alexander Walters : > >>>What incantation do you need to do to make that behavior