On Thu, 31 Dec 2009 22:57:05 -0800, Karthik Tharavaad <[email protected]> wrote: > 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
There is a bug in the error handling (fixed in tonight's SIP snapshot). You need to use pickle protocol 2. Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
