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/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to