[issue21669] Custom error messages when print & exec are used as statements

2014-08-22 Thread Nick Coghlan
Nick Coghlan added the comment: For the record, I just posted the Q&A reference to Stack Overflow: https://stackoverflow.com/questions/25445439/what-does-syntaxerror-missing-parentheses-in-call-to-print-mean-in-python/ -- ___ Python tracker

[issue21669] Custom error messages when print & exec are used as statements

2014-06-16 Thread Nick Coghlan
Nick Coghlan added the comment: I went ahead and committed the v2 patch, as I think it's already an improvement over the generic message. Any further significant tweaks to the heuristics or changes to the error messages can be handled in separate issues. -- resolution: -> fixed stage:

[issue21669] Custom error messages when print & exec are used as statements

2014-06-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset 2b8cd2bc2745 by Nick Coghlan in branch '3.4': Issue #21669: Special case print & exec syntax errors http://hg.python.org/cpython/rev/2b8cd2bc2745 New changeset 36057f357537 by Nick Coghlan in branch 'default': Merge issue #21669 from 3.4 http://hg.p

[issue21669] Custom error messages when print & exec are used as statements

2014-06-08 Thread Nick Coghlan
Nick Coghlan added the comment: My main aim here is to offer a custom error message that can be looked up in an internet search (likely ending up at a Stack Overflow answer - which we could create in advance of the 3.4.x release that includes this change). That answer can then explain the variou

[issue21669] Custom error messages when print & exec are used as statements

2014-06-08 Thread Glyph Lefkowitz
Glyph Lefkowitz added the comment: Just my 2ยข here: rather than debating cases in the abstract, it would be interesting to 'pip install' a couple of popular 2.x-only packages and see if the error message is an improvement. My experience is that learners don't hit this so much by writing their

[issue21669] Custom error messages when print & exec are used as statements

2014-06-07 Thread Nick Coghlan
Nick Coghlan added the comment: Updated patch with the heuristics factored out into a helper function, with a more detailed explanation and additional logic to handle compound statements. >>> def foo(): ... print bar File "", line 2 print bar ^ SyntaxError: Missing parenth

[issue21669] Custom error messages when print & exec are used as statements

2014-06-06 Thread Guido van Rossum
Guido van Rossum added the comment: I also found some amusing false positives (syntax errors that weren't valid print statements in Python 2): print [/ print / print )# but not "print)" ! print] None of these matter though. Perhaps more concerning is how many things are v

[issue21669] Custom error messages when print & exec are used as statements

2014-06-06 Thread Guido van Rossum
Guido van Rossum added the comment: Nice! I put it through a bit of a torture test and found a few odd corners. E.g. it doesn't catch this: if 1: print 42 nor this: if 1: print 42 nor this: def foo(): print 42 I also notice that if the printed expression starts

[issue21669] Custom error messages when print & exec are used as statements

2014-06-06 Thread Nick Coghlan
Nick Coghlan added the comment: Heuristic based approach that just does a fairly simple check for the syntax error text starting with "print " or "exec " when the text doesn't contain a left parenthesis. This will still miss a few cases where the left parenthesis is inside a larger expression

[issue21669] Custom error messages when print & exec are used as statements

2014-06-05 Thread Guido van Rossum
Guido van Rossum added the comment: Yes, something like that. Don't change the grammar, just hack the heck out of the error message. -- ___ Python tracker ___ __

[issue21669] Custom error messages when print & exec are used as statements

2014-06-05 Thread Nick Coghlan
Nick Coghlan added the comment: As in, putting something either in the SyntaxError constructor or else in the parser code that emits them? I like that - the fact my initial approach broke a test was rather concerning, and a change purely on the error handling side should be much safer. -

[issue21669] Custom error messages when print & exec are used as statements

2014-06-05 Thread Guido van Rossum
Guido van Rossum added the comment: I'm sorry, but I find this way too intrusive, and a little risky too (I'm not sure how to verify even that the new parser accepts exactly the same set of programs as the old version). I would much prefer a solution to this particular issue along the lines of

[issue21669] Custom error messages when print & exec are used as statements

2014-06-05 Thread Nick Coghlan
New submission from Nick Coghlan: I realised my experiment with supporting implicit calls could potentially be used as the basis for a patch that reported more specific error details when "print" and "exec" were used as statements, so I went ahead and updated it to do so. The initial patch ha