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

R. David Murray report at bugs.python.org
Tue Dec 19 22:13:09 EST 2017


R. David Murray <rdmurray at bitdance.com> 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 decoding.  But when encoding, it must produce bytes, because "ASCII" is a *byte* encoding, not a unicode encoding (unicode is ascii compatible, but it is neither ascii nor bytes).  You might have to write the PR yourself, I'm not sure if anyone else will be interested (but some of the people on the core-mentorship mailing list might be).

StringIO is specifically designed to only operate on strings.  If you want to decode the bytes you feed it, you have to do that.  This is an intentional design.

Further discussion of ways to improve the situation should move to the python-idea mailing list.  There's really nothing to do here from a bug tracker perspective, unless you want to open an enhancement request as mentioned above.

----------

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


More information about the Python-bugs-list mailing list