Skip to content

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jul 27, 2021

@pablogsal
Copy link
Member Author

CC: @ammaraskar this was the PR I had prepared. If you want, we could explore incorporate your suggestions here

@ammaraskar
Copy link
Member

Nice: image


My thinking for suggesting Did you mean print(...) (not sure if the one with end=' ' is worth the added rule) is that this is the type of mistake which beginners are likely to make while blindly following an outdated tutorial or copying a snippet. For those cases, it's almost better to be verbose and show close to what change they should make rather than just say "missing parentheses" which might be too jargony.

@pablogsal
Copy link
Member Author

My thinking for suggesting Did you mean print(...) (not sure if the one with end=' ' is worth the added rule) is that this is the type of mistake which beginners are likely to make while blindly following an outdated tutorial or copying a snippet. For those cases, it's almost better to be verbose and show close to what change they should make rather than just say "missing parentheses" which might be too jargony.

I am a bit skeptical but I trust your juzguement. I have updated the PR with the changes you propose :)

_PyPegen_check_legacy_stmt(p, a) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Missing parentheses in call to '%U'.", a->v.Name.id) : NULL}

| a=NAME b=star_expressions {
_PyPegen_check_legacy_stmt(p, a) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do the carets for this end up? If they're at the end of the expression, LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> print a+b, c+d, f()
  File "<stdin>", line 1
    print a+b, c+d, f()
    ^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

>>> 3,4 , [print 3+4, 6+7, 8], 34
  File "<stdin>", line 1
    3,4 , [print 3+4, 6+7, 8], 34
           ^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

>>> print {3+4, 6+7, 8}, 45, 6
  File "<stdin>", line 1
    print {3+4, 6+7, 8}, 45, 6
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

>>> (print {3+4, 6+7, 8}, 45, 6), 5
  File "<stdin>", line 1
    (print {3+4, 6+7, 8}, 45, 6), 5
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect 👌

@pablogsal pablogsal merged commit ecc3c8e into python:main Jul 27, 2021
@pablogsal pablogsal deleted the bpo-34013 branch July 27, 2021 20:30
@pablogsal pablogsal added the needs backport to 3.10 only security fixes label Jul 27, 2021
@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-27393 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 27, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 27, 2021
…the parser (pythonGH-27392)

(cherry picked from commit ecc3c8e)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
miss-islington added a commit that referenced this pull request Jul 27, 2021
…the parser (GH-27392)

(cherry picked from commit ecc3c8e)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants