Marc-Andre Lemburg added the comment:

On 18.12.2015 20:25, R. David Murray wrote:
> I wonder if we originally only had UnicodeError and it got split later but 
> these codecs were never updated.  The codecs date back to the start of 
> unicode support in python2, I think.

UnicodeDecodeError and UnicodeEncodeError were added in Python 2.3
as part of the more flexible error handlers.

> Adding MAL, he's likely to have an opinion on this ;)
> 
> Oh, right.  The more likely possibility is that there was (in python2) no way 
> to know if the operation was (from the user's POV) encoding or decoding when 
> the codec was called.  In python3 we do know, when the codec is called via 
> encode/decode, but the codecs are still generic in principle.  So yeah, we 
> need MAL's opinion.  (Or, I could be completely confused, since I always 
> found encode/decode confusing in python2 :)

There's a clear direction with codecs:
- encode: transform to the encoded data
- decode: transform back from the encoded data

Take e.g. the hex codec. It encodes data into hex format and
decodes from hex format back into the original data.

The IDNA codecs transforms Unicode domains into the IDNA format
(.encode()) and back to Unicode again (.decode()).

It was added in Python 2.3 as well, so I guess it was just
an overlap/oversight that it was not adapted to the new error
classes.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25880>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to