[issue32028] Syntactically wrong suggestions by the new custom print statement error message

Nick Coghlan report at bugs.python.org
Wed Nov 15 01:35:19 EST 2017


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Given the symptoms (stripping 4 spaces + "pr" from the start of the line, leaving "int " behind), it looks like we're not stripping the leading whitespace when determining the text to include in the suggested print() call.

To reproduce this at the REPL, you can use an if statement (first example uses a 4 space indent, the second uses an 8 space indent):

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

```

----------
stage:  -> test needed
versions: +Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32028>
_______________________________________


More information about the Python-bugs-list mailing list