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() ##############################################################################