From d2cb98c134f24299efc7fe10a376e8151ced1f97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Oct 2016 19:44:11 +0100 Subject: [PATCH] Pickle test additions These are not working yet for all combinations of builtin and PY3 The goal is to have a sensible default error that states that pickling is not supported. --- Examples/test-suite/python/python_pickle_runme.py | 8 ++++++++ Examples/test-suite/python_pickle.i | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/Examples/test-suite/python/python_pickle_runme.py b/Examples/test-suite/python/python_pickle_runme.py index f7f8395c2..b58cca471 100644 --- a/Examples/test-suite/python/python_pickle_runme.py +++ b/Examples/test-suite/python/python_pickle_runme.py @@ -18,3 +18,11 @@ if python_pickle.cvar.debug: pickle_string = pickle.dumps(p) newp = pickle.loads(pickle_string) check(newp) + +# Not yet working... some crash and others are not producing a sensible "can't be pickled" error +#nfp = python_pickle.NotForPickling("no no") +#print nfp.__reduce__() +#pickle_string = pickle.dumps(nfp) +#print pickle_string +#newp = pickle.loads(pickle_string) +#print newp.msg diff --git a/Examples/test-suite/python_pickle.i b/Examples/test-suite/python_pickle.i index 3c03b177c..fbb3d05a8 100644 --- a/Examples/test-suite/python_pickle.i +++ b/Examples/test-suite/python_pickle.i @@ -48,4 +48,9 @@ struct PickleMe { std::cout << "In C++ constructor " << " [" << msg << "]" << std::endl; } }; + +struct NotForPickling { + std::string msg; + NotForPickling(const std::string& msg) : msg(msg) {} +}; %}