[Python-Dev] Reintroduce or drop completly hex, bz2, rot13, ... codecs (original) (raw)
Victor Stinner victor.stinner at haypocalc.com
Thu Jun 10 14:16:46 CEST 2010
- Previous message: [Python-Dev] Reintroduce or drop completly hex, bz2, rot13, ... codecs
- Next message: [Python-Dev] Reintroduce or drop completly hex, bz2, rot13, ... codecs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le jeudi 10 juin 2010 12:30:01, Walter Dörwald a écrit :
Codecs support several types of error handling that don't make sense for transform()/untransform(). What should 'abc'.decode('hex', 'replace') do?
You mean 'abc'.transform('hex', 'replace'), right?
Error handler is useful for encoding codecs (the input type is different than the output type), but I don't see how it can used with hex, rot13, bz2, ... (we decided that .transform() and .untransform() will use the same input and output types). Even if bz2+xmlcharref can be something funny :-)
.transform() and .untransform() should have only one argument.
(If you would really like to play with the error handler, you can still use codecs.encode(name, errors) and codecs.decode(name, errors).)
.transform() and .untransform() have to be simple. If you want to control the codec, why not using directly the real API? Examples:
- base64.b64encode() has an optional altchars argument
- bz2.compress() has an optional compresslevel argument
- etc.
I don't see how altchars or compresslevel can be added to .transform() / .untransform(). (**kw would be something really ugly.)
(In 2.6 it raises an assertion error, because errors must be strict)
hex, bz2, rot13, ... codecs should also raise an error if errors is not "strict" (or None which means "strict") in Python3.
-- Victor Stinner http://www.haypocalc.com/
- Previous message: [Python-Dev] Reintroduce or drop completly hex, bz2, rot13, ... codecs
- Next message: [Python-Dev] Reintroduce or drop completly hex, bz2, rot13, ... codecs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]