RuntimeWarning: tp_compare

Bruno Barberi Gnecco brunobgDELETETHIS at
Thu Oct 11 17:23:30 CEST 2007

Chris Mellon wrote:
> On 10/9/07, Bruno Barberi Gnecco
> <brunobgDELETETHIS at> wrote:
>>        I'm getting the following exception when I call an external extension
>>/usr/lib/python2.5/ RuntimeWarning: tp_compare didn't return -1 or -2 for
>>   return _active[_get_ident()]
>>Traceback (most recent call last):
>>   File "", line 77, in <module>
>>     testPlace()
>>   File "", line 41, in testPlace
>>     data = db.getDescription(event['id'])
>>   File "", line 28, in getDescription
>>     return self.getRow(query, (id,))
>>   File "../", line 73, in getRow
>>     self.readlock.acquire()
>>   File "/usr/lib/python2.5/", line 94, in acquire
>>     me = currentThread()
>>   File "/usr/lib/python2.5/", line 697, in currentThread
>>     return _active[_get_ident()]
>>UnicodeEncodeError: 'ascii' codec can't encode character u'\xfa' in position 52: ordinal
>>not in range(128)
>> > /usr/lib/python2.5/
>>-> return _DummyThread()
>>        Note that the error occurs *after* the call that I isolated as
>>affecting it (pytst.scan(), in the case). This doesn't happen for simple,
>>isolated cases, but googling for "tp_compare threading" shows a lot of
>>similar issues. Does anybody here know what this could be about? Any ideas
>>to debug or work around it?
> The various thread issues in the traceback aside, it looks like the
> problem is that you passed a unicode object to pytst, which only
> accepts plain (ascii) strings.

	That seems to have solved it. Thanks!

Bruno Barberi Gnecco <>
There is no time like the pleasant.

More information about the Python-list mailing list