[Python-Dev] transform() and untransform() methods, and the codec registry

Guido van Rossum guido at python.org
Fri Dec 10 18:54:56 CET 2010

On Thu, Dec 9, 2010 at 11:17 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Thu, 9 Dec 2010 13:55:08 -0500
> Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote:
>> On Thu, Dec 9, 2010 at 1:42 PM, Guido van Rossum <guido at python.org> wrote:
>> ..
>> > string-string transforms use the same namespace even though the
>> > typical transform only supports one or the other. E.g. IMO all of the
>> > following should raise LookupError:
>> >
>> >>>> b'abc'.transform('rot13')
>> > Traceback (most recent call last):
>> > ..
>> >    return (input.translate(rot13_map), len(input))
>> > TypeError: expected an object with the buffer interface
>> This is actually *very* misleading because
>> >>> 'abc'.transform('rot13')
>> 'nop'
>> works even though 'abc' is not "an object with the buffer interface".
> Agreed. It was already pointed out in the parent thread.
> I would say my opinion on keeping transform()/untransform() is +0 if
> these error messages (and preferably the exception type as well) get
> improved. Otherwise we'd better revert them and add a more polished
> version in 3.3.

Let me change my opinion then and say that I'm -1 on keeping the
confusing situation. It can be fixed either by postponing transform()
until 3.3 or by fixing the error checking and namespace issue.

Sorry about the reversal of pronouncements, but my original approval
was very weak indeed and mostly driven by "stick to status quo unless
there's a serious problem". The followup made it clear that the errors
and namespace issue are more seriously than I estimated at first.

--Guido van Rossum (python.org/~guido)

More information about the Python-Dev mailing list