[PyKDE] Found cure for bizarre backtrace - ???

Bill Soudan bill at soudan.net
Tue Jul 2 17:07:00 BST 2002


On Tue, 2 Jul 2002, Bill Soudan wrote:

> I'm going to do some more debugging today.  If I can't find anything else 
> out about the exception, I'll prune the code down and post it.

Alright, I've narrowed the culprit down to my subclassed QListViewItem.
I add a single MonitorItem to the listview, send rapid-fire XMLRPC 
messages to the GUI, and when I click on the item, the exception occurs.

class MonitorItem(QListViewItem):
  def __init__(self, host, port, parent = None, name = None):
    QListViewItem.__init__(self, parent, name)

  def text(self, column):
    return 'test'

I've found two different ways to get rid of the dump:

1) don't override the text method.  Not really practical.

2) modify the text method to return QString('text') instead of just 'text'.

I always thought PyQt is supposed to convert between Python strings and
QStrings automatically.  I reviewed the docs though and they don't
specifically say whether returning Python strings from C++ methods is
acceptable, nor does QListViewItem have any caveats listed.  So is #2 the
proper fix?

If not, the fact that this is completely unrelated to the xmlrpc code
leads me to believe there's something wacky going on under the hood that I
don't know about.  While eventually, in the final version of the code, I
want to have XMLRPC calls that manipulate the listview, I have removed all
coupling in the current version.

Is there some sort of corruption occuring when I return a Python string 
from the text method that later triggers the strange exception?  I've 
listed it below for reference again.

In the meantime, I'm going to keep pruning and once I get something
reasonably short I'll post it to the list.

Bill

---

Exception happened during processing of request from ('xxx.xxx.xxx.xxx', 
36408)
Traceback (most recent call last):
  File "/usr/lib/python2.2/SocketServer.py", line 221, in handle_request
    self.process_request(request, client_address)
  File "/usr/lib/python2.2/SocketServer.py", line 240, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.2/SocketServer.py", line 253, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.2/SocketServer.py", line 513, in __init__
    self.setup()
  File "/usr/lib/python2.2/SocketServer.py", line 557, in setup
    self.rfile = self.connection.makefile('rb', self.rbufsize)
AttributeError: 'str' object has no attribute 'sipThis'




More information about the PyQt mailing list