This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients ajaksu2, benjamin.peterson, dmalcolm, ezio.melotti, oliver_gramberg, rhettinger, sean_gillespie, serhiy.storchaka
Date 2012-10-25.00:16:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351124186.74.0.815374224935.issue1634034@psf.upfronthosting.co.za>
In-reply-to
Content
Looking at the changes in the patch it seems to me that, in at least a few cases, it's better to have a bare "invalid syntax" than a misleading error.
For example:

     >>> dict(a = i for i in range(10))
+    SyntaxError: invalid syntax - ')' expected

The () are ok, the message is misleading.


 >>> obj.None = 1
+SyntaxError: invalid syntax - name expected

'name' here is a bit vague.

 
 >>> def f(x, None):
 ...     pass
+SyntaxError: invalid syntax - ')' expected

 >>> def f(*None):
 ...     pass
+SyntaxError: invalid syntax - ')' expected

Here the () are ok too.

 
 >>> def f(**None):
 ...     pass
+SyntaxError: invalid syntax - name expected

Here I would have expected the "')' expected" like in the previous example, but there's "name" instead (which is a bit better, albeit inconsistent).


I wouldn't consider this an improvement, but for other situations the error message is probably useful.
I see 3 options here:
1) we find a way to show the expected token only when the message is not misleading;
2) if the expected token is useful more often than it is misleading, then we could apply the patch as is;
3) if it is misleading more often than it is useful, it's probably better to reject the patch.
History
Date User Action Args
2012-10-25 00:16:27ezio.melottisetrecipients: + ezio.melotti, rhettinger, sean_gillespie, ajaksu2, oliver_gramberg, benjamin.peterson, dmalcolm, serhiy.storchaka
2012-10-25 00:16:26ezio.melottisetmessageid: <1351124186.74.0.815374224935.issue1634034@psf.upfronthosting.co.za>
2012-10-25 00:16:26ezio.melottilinkissue1634034 messages
2012-10-25 00:16:25ezio.melotticreate