[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2020-11-06 Thread Irit Katriel
Change by Irit Katriel : -- stage: test needed -> versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.2, Python 3.3 ___ Python tracker ___

[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2011-11-16 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +pitrou versions: +Python 3.3 -Python 3.1 ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2009-06-26 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: The problem here is not the bytes object: it is correctly coerced to a string. The problem is the binary stream, which cannot accept strings. We could maybe detect common errors and add a check at the beginning of the print() function? something like

[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2009-06-18 Thread Georg Brandl
Georg Brandl added the comment: How would you propose to fix this? print() should certainly not catch all TypeErrors and raise a new one... Maybe exception chaining could be used, so that print raises a TypeError of its own with the cause being the original message? -- nosy: +georg.br

[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2009-06-17 Thread R. David Murray
New submission from R. David Murray : The documentation for the print function specifies that the input argument is coerced to string. However, if bytes are passed and the file= parameter points to a file open for binary write, the error message produced is: >>> out = open('temp', 'wb') >>> pri