[Python-Dev] why doesn't print pass unicode strings on to the file object?
Guido van Rossum
guido@python.org
Tue, 18 Sep 2001 09:24:20 -0400
> _fields = {'encode':0,'decode':1,'reader':2,'writer':3}
> class CodecInfo(tuple):
> __dynamic__ = 0
> def __getattr__(self, name):
> try:
> return self[_fields[name]]
> except KeyError:
> raise AttributeError, name
You want to change that raise statement into
return tuple.__getattr__(self, name)
Remember, new-style __getattr__ *replaces* the built-in getattr
operation; it doesn't only get invoked when the built-in getattr
doesn't find the attribute, like it does for classic classes.
(I'm still considering whether this is too backwards incompatible; we
could have two getattr hooks, one old-style and one new-style.)
--Guido van Rossum (home page: http://www.python.org/~guido/)