The metaclass (SwigPyObjectType) for SWIG objects was not defined in a way that let importlib successfully import the Python wrappers. The pickle module failed because it couldn't determine what module the SWIG wrapped objects are in. I've changed the definition of SwigPyObjectType using more normal builtin type definitions. There are still some open questions: - None of the builtin types, like swig_static_var_getset_descriptor and SwigPyObject are added into any module. No call to PyModule_AddObject is made, so isinstance cannot be used for any wrapped type, all of which are derived from SwigPyObject. Closes #808
20 lines
387 B
Python
20 lines
387 B
Python
import python_pickle
|
|
|
|
import pickle
|
|
|
|
def check(p):
|
|
msg = p.msg
|
|
if msg != "hi there":
|
|
raise RuntimeError("Bad, got: " + msg)
|
|
|
|
python_pickle.cvar.debug = False
|
|
|
|
p = python_pickle.PickleMe("hi there")
|
|
check(p)
|
|
|
|
r = p.__reduce__()
|
|
if python_pickle.cvar.debug:
|
|
print "__reduce__ returned:", r
|
|
pickle_string = pickle.dumps(p)
|
|
newp = pickle.loads(pickle_string)
|
|
check(newp)
|