changeset 229:d51b3d120c85

Only attempt to convert an Octave object if it is a pyobject * octave_to_python.cc (octvalue_to_pyobj): Only attempt to get an associated Python object if the argument is a pyboject instance.
author Mike Miller <mtmiller@octave.org>
date Wed, 20 Jul 2016 12:36:47 -0700
parents 2a9956be24aa
children 262832ae684f
files octave_to_python.cc
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/octave_to_python.cc	Wed Jul 20 12:18:22 2016 -0700
+++ b/octave_to_python.cc	Wed Jul 20 12:36:47 2016 -0700
@@ -278,12 +278,14 @@
       octvalue_to_pyarr (py_object, octvalue);
     else if (octvalue.is_map ())
       octmap_to_pyobject (py_object, octvalue.map_value ());
-    else if (octvalue.is_object ()) {
-      octave_value_list tmp = feval ("getid", ovl (octvalue), 1);
-      std::string hexid = tmp(0).string_value ();
-      // FIXME: added a messy ref to __InOct__ in __main__, find a better way
-      py_object = boost::python::import ("__main__").attr ("__InOct__")[hexid];
-    } else
+    else if (octvalue.is_object () && octvalue.class_name () == "pyobject")
+      {
+        octave_value_list tmp = feval ("getid", ovl (octvalue), 1);
+        std::string hexid = tmp(0).string_value ();
+        // FIXME: added a messy ref to __InOct__ in __main__, find a better way
+        py_object = boost::python::import ("__main__").attr ("__InOct__")[hexid];
+      }
+    else
       throw value_convert_exception (
         "Conversion from Octave value not implemented");
   }