comparison @pyobject/pyobject.m @ 408:f833e29b2c12

Simplify conversion where existing Python object argument expected (fixes issue #67) * __py_struct_from_dict__.cc (F__py_isinstance__, F__py_struct_from_dict__): Use pytave::pyobject_unwrap_object and simplify surrounding code. * oct-py-types.cc (pytave::extract_py_scalar_map): Raise Octave errors instead of throwing exceptions, reword error messages. * @pyobject/pyobject.m: Add %!error tests for struct conversion failure.
author Mike Miller <mtmiller@octave.org>
date Tue, 02 May 2017 10:06:14 -0700
parents 6c316b5f30f7
children 8a26a4e649ba
comparison
equal deleted inserted replaced
407:78448e4de20a 408:f833e29b2c12
407 %! a = struct ("a", 1, "b", 2, "three", 3); 407 %! a = struct ("a", 1, "b", 2, "three", 3);
408 %! b = pycall ("dict", pyargs ("a", 1, "b", 2, "three", 3)); 408 %! b = pycall ("dict", pyargs ("a", 1, "b", 2, "three", 3));
409 %! c = struct (b); 409 %! c = struct (b);
410 %! assert (c, a) 410 %! assert (c, a)
411 411
412 %!error struct (pyeval ("{1:2, 3:4}"));
413 %!error struct (pyobject ("this is not a dict"))
414 %!error struct (pyobject ({1, 2, 3}))
415 %!error struct (pyobject ())
416
412 ## Octave fails to resolve function overloads via function handles 417 ## Octave fails to resolve function overloads via function handles
413 %!xtest 418 %!xtest
414 %! fn = @double; 419 %! fn = @double;
415 %! x = pyobject (int64 (42)); 420 %! x = pyobject (int64 (42));
416 %! assert (fn (x), double (x)) 421 %! assert (fn (x), double (x))