[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-20 Thread Christoph Reiter
Change by Christoph Reiter : -- nosy: -lazka ___ Python tracker ___ ___

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-19 Thread R. David Murray
R. David Murray added the comment: Yes, if that protocol existed the errors would be clearer. But it doesn't, for historical reasons, and that is unlikely to change. You are welcome to submit an enhancement request to make quopri accept string as an argument when

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-19 Thread Alexey Luchko
Alexey Luchko added the comment: 1. On quopri. It is counter-intuitive despite the clear statement in the doc-string. Quoted-printable is used mostly for text encoding. (It would be quite awkward and inefficient to use it for binary data.) My case: I have a text and I

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-19 Thread R. David Murray
R. David Murray added the comment: That's type checking. Not type checking is to call the method that writes the data, expecting the object to handle the bytes it is passed, and then that object raises an error to indicate that it cannot. There is no protocol that

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-19 Thread Alexey Luchko
Alexey Luchko added the comment: I didn't mean type checking. The point is that since string and bytes are different types, then binary and text files are actually much more different than before python 3. Therefore they better be of different protocols. Then inside

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-12 Thread R. David Murray
R. David Murray added the comment: We generally don't do advance type checking (look before you leap) in Python. This allows a type the programmer hadn't planned for to be used as long as it "quacks like" the expected type (this is called duck typing). So the error

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-12 Thread Alexey Luchko
Alexey Luchko added the comment: Yes. With io.BytesIO() output, it works. However, this kind of error messages is quite very confusing. It better be possible to distinguish binary and text streams, so one (including quopri module) could tell it won't work in advance %)

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-10 Thread R. David Murray
R. David Murray added the comment: Right, this is not a bug, it is working as documented. You could submit an enhancement request, but I'm surprised to find that anyone is actually using that module :) We unfortunately have multiple implementations of quoted printable

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-10 Thread Christoph Reiter
Christoph Reiter added the comment: The documentation [0] states: "input and output must be binary file objects" and you are not passing a binary file object. [0] https://docs.python.org/3.6/library/quopri.html#quopri.decode -- nosy: +lazka

[issue32268] quopri.decode(): string argument expected, got 'bytes'

2017-12-10 Thread Alexey Luchko
New submission from Alexey Luchko : $ python3 -c 'import io, quopri; quopri.decode(io.StringIO("some initial text data"), io.StringIO())' Traceback (most recent call last): File "", line 1, in File