ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

print and exec have custom syntax error messages when using old syntax

Open slide opened this issue 6 years ago • 3 comments

>>> print foo
  File "<stdin>", line 1
    print foo
            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(foo)?

slide avatar Feb 19 '18 18:02 slide

>>> exec foo
  File "<stdin>", line 1
    exec foo
           ^
SyntaxError: Missing parentheses in call to 'exec'

slide avatar Feb 19 '18 18:02 slide

https://github.com/python/cpython/blob/43c0f1ac5ed8bc9c3bd048d2ce4de4c98a83de99/Objects/exceptions.c#L2893

slide avatar Feb 19 '18 19:02 slide

There are tests for these in:

  • test_grammar.test_former_statements_refer_to_builtins
  • test_print.TestPy2MigrationHint (in 3.6)
  • test_exceptions.testSyntaxErrorMissingParens (in 3.6)

slozier avatar Aug 27 '22 01:08 slozier