Brett Cannon wrote: > On 9/4/06, Neal Norwitz <[EMAIL PROTECTED]> wrote: >> >> There are 3 bugs currently listed in PEP 356 as blocking: >> http://python.org/sf/1551432 - __unicode__ breaks on exception >> classes > > > I replied on the bug report, but might as well comment here. > > The problem with this bug is that BaseException now defines a __unicode__() > method in its PyMethodDef. That intercepts the unicode() call on the class > and it complains it was not handed an instance. I guess the only way to > fix this is to toss out the __unicode__() method and change the tp_str > function > to return Unicode as needed (unless someone else has a better idea). Or > the bug can be closed as Won't Fix.
The proper fix would be to introduce a tp_unicode slot and let this decide what to do, ie. call .__unicode__() methods on instances and use the .__name__ on classes. I think this would be the right way to go for Python 2.6. For Python 2.5, just dropping this .__unicode__ method on exceptions is probably the right thing to do. The reason why the PyObject_Unicode() function tries to be smart here is that we don't have a tp_unicode slot (to complement tp_str). It's obvious that this is not perfect, but only a work-around. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Sep 05 2006) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: _______________________________________________ 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