This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lemburg
Recipients amaury.forgeotdarc, benjamin.peterson, christoph, davidfraser, georg.brandl, hodgestar, lemburg, ncoghlan, pitrou
Date 2008-06-11.09:47:15
SpamBayes Score 6.6069447e-07
Marked as misclassified No
Message-id <484F9F1D.4050303@egenix.com>
In-reply-to <1213176744.02.0.830768417637.issue2517@psf.upfronthosting.co.za>
Content
On 2008-06-11 11:32, Nick Coghlan wrote:
> Nick Coghlan <ncoghlan@gmail.com> added the comment:
> 
> As far as I am concerned, the implementation of PyObject_Unicode in
> object.c has a bug in it: it should NEVER be retrieving __unicode__ from
> the instance object. The implementation of PyObject_Format in abstract.c
> shows the correct way to retrieve a pseudo-slot method like __unicode__
> from an arbitrary object.

The only difference I can spot is that the PyObject_Format() code
special cases non-instance objects.

> Line 482 in object.c is the offending line:
> 	func = PyObject_GetAttr(v, unicodestr);
> 
> Fix that bug, then add a __unicode__ method back to Exception objects
> and you will have the best of both worlds.

I'm not sure whether that would really solve anything.

IMHO, it's better to implement the tp_unicode slot and then
check that before trying .__unicode__ (as mentioned in the comment
in PyObject_Unicode()).
History
Date User Action Args
2008-06-11 09:47:34lemburgsetspambayes_score: 6.60694e-07 -> 6.6069447e-07
recipients: + lemburg, georg.brandl, amaury.forgeotdarc, ncoghlan, davidfraser, pitrou, benjamin.peterson, christoph, hodgestar
2008-06-11 09:47:17lemburglinkissue2517 messages
2008-06-11 09:47:16lemburgcreate