[PyQt] Pickling Problems

Karthik Tharavaad karthiktharavaad at gmail.com
Fri Jan 1 06:57:05 GMT 2010


I've been trying to implement pickling support on some of my own classes
which inherits QObject, however, I always crash Python when I attempt to run
the application. The simple test program below illustrates my problem:

from PyQt4.QtCore import *

class Foo( QObject ):

    def __init__(self,msg="hello",parent=None):
        super(Foo,self).__init__(parent)
        self.msg = msg

    def __getstate__(self):
        return self.msg

    def __setstate__(self,state):
        self.msg = state


if __name__ == "__main__":
    import pickle
    foo = Foo("bar")
    foos = pickle.dumps(foo)
    del foo
    bar = pickle.loads( foos )
    print( bar.msg )

Attempting to run this program crashes Python
I'm running windows 7 and lattest version of PyQt and Qt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100101/f1202a8e/attachment.html


More information about the PyQt mailing list