[issue30597] Show expected input in custom "print" error message

Nick Coghlan report at bugs.python.org
Fri Jun 9 00:33:11 EDT 2017


Nick Coghlan added the comment:

Ah, re-reading the comments when reviewing Sanyam's patch, I just remembered the problem with the "print >> sys.stderr, output" case, which is that it isn't a syntax error, it's a runtime type error:

```
>>> print >> sys.stderr, "message"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'
```

So if we ever wanted to provide a specialised prompt for that, it would need to go into the right-shift operator implementation as a final check before raising the type error, rather than here.

That reduces the cases we need to handle here to just the default one and the softspace one, where a trailing comma in the statement text gets replaced with ", end=' '".

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30597>
_______________________________________


More information about the Python-bugs-list mailing list