This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients barry, ezio.melotti, flox, ncoghlan
Date 2013-05-10.03:52:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
To summarize:
 * str.encode does only str->bytes;
 * bytes.decode does only bytes-> str;
 * codecs.encode/decode do obj->obj;

The things that could go wrong are:
 1) the input type is wrong (i.e. the codec doesn't accept the type of the input);
 2) the input value is invalid;
 3) for str.encode/bytes.decode only, the output type is wrong (i.e. the codec returned a non-bytes/non-str object);

My patch only covers 3.  The four new exceptions suggested by Nick in msg187704 would cover the first 2 cases.
For str.encode/bytes.decode, if we knew the input type accepted by the codec we could also provide a better error message (e.g. "codecs accepts '...', not '...'; use ... instead"), but we don't.
Date User Action Args
2013-05-10 03:52:40ezio.melottisetrecipients: + ezio.melotti, barry, ncoghlan, flox
2013-05-10 03:52:40ezio.melottisetmessageid: <>
2013-05-10 03:52:40ezio.melottilinkissue17828 messages
2013-05-10 03:52:40ezio.melotticreate