kb 04.09.2011 14:10 Gajim

иногда python очень говно. вот нашел я багу в pypy, когда у объекта делается __repr__ и тот возвращает u'%s' % u'йцукен' — происходит unicode decode error. пошел создал багу у pypy в трекере, всё должно было быть хорошо. и тут оказывается (кроме того, что уведомления до меня не доходили из-за блядской яндекс.хуёчты), что бага эта есть в CPython, и более того, если __repr__ возвращает юникод — вы можете сосать хер кроме одного грязного хака, который позволяет вам сделать '%s' % O(), чтоб получить юникод-строку, возвращаемую repr(O()). короче, говно.

With a __repr__ that returns an unencodable unicode string, you will get an
encoding error on CPython if you try to do anything at all, like str(O()) or
repr(O()) or print O() or `O()`. Even doing '%r' % O(). It seems that '%s' %
O() is the only thing that you can do.

Indeed, I can't believe it, but looking at the source code of CPython, there is
a special function _PyObject_Str() that is called *only* from '%s' formatting.
All other places call PyObject_Str() or PyObject_Repr(), which will encode the
unicode string. It makes no sense to me... What should we do? Copy this
horribly strange special case???

https://bugs.pypy.org/issue857

Do you really want to delete ?