def loads(self, buf): class PersUnpickler(pickle.Unpickler): def persistent_load(subself, obj): return self.persistent_load(obj) f = StringIO(buf) u = PersUnpickler(f) return u.load()