From 104e5876072e28f59a0b25780e6e65b85e47d8b9 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Mon, 29 Oct 2018 21:06:34 +0100 Subject: [PATCH] try to use basic converter in pickle_converter --- openmath/convert_pickle.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/openmath/convert_pickle.py b/openmath/convert_pickle.py index 0c63f9b..d3afd73 100644 --- a/openmath/convert_pickle.py +++ b/openmath/convert_pickle.py @@ -141,10 +141,22 @@ def to_python(self, obj): def to_openmath(self, o=None, sobj=None): assert o is None or sobj is None + + if o is not None: + try: + return self._basic_converter.to_openmath(o) + except openmath.convert.CannotConvertError: + pass + except ValueError: + pass + + if sobj is None: sobj = pickle.dumps(o, protocol=2) file = six.BytesIO(sobj) + + return OMUnpickler(file, self).load() ##############################################################################