Mercurial > octave
changeset 24100:4d9ceaf17dda
return empty matrix if meta.*.fromName fails (bug #52096)
* ov-classdef.cc (class_fromName): Call lookup_class with
error_not_found = false.
(package_fromName): Call find_package with error_not_found = false.
(lookup_package): New args, error_if_not_found and load_if_not_found.
Pass them to find_package.
* test/classdef/classdef.tst: New tests.
author | Piotr Held <pjheld@gmail.com> |
---|---|
date | Fri, 22 Sep 2017 17:24:15 -0700 |
parents | b47cbbfff501 |
children | e5a504929efb |
files | libinterp/octave-value/ov-classdef.cc test/classdef/classdef.tst |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.cc Mon Sep 25 13:02:51 2017 -0700 +++ b/libinterp/octave-value/ov-classdef.cc Fri Sep 22 17:24:15 2017 -0700 @@ -527,7 +527,7 @@ std::string name = args(0).xstring_value ("fromName: CLASS_NAME must be a string"); - retval(0) = to_ov (lookup_class (name)); + retval(0) = to_ov (lookup_class (name, false)); return retval; } @@ -3107,11 +3107,12 @@ } static cdef_package -lookup_package (const std::string& name) +lookup_package (const std::string& name, bool error_if_not_found = true, + bool load_if_not_found = true) { cdef_manager& cdm = octave::__get_cdef_manager__ ("lookup_package"); - return cdm.find_package (name); + return cdm.find_package (name, error_if_not_found, load_if_not_found); } static octave_value_list @@ -3124,7 +3125,7 @@ std::string name = args(0).xstring_value ("fromName: PACKAGE_NAME must be a string"); - retval(0) = to_ov (lookup_package (name)); + retval(0) = to_ov (lookup_package (name, false)); return retval; }
--- a/test/classdef/classdef.tst Mon Sep 25 13:02:51 2017 -0700 +++ b/test/classdef/classdef.tst Fri Sep 22 17:24:15 2017 -0700 @@ -86,3 +86,6 @@ %!test <*51715> %! x = containers.Map; %! assert (isobject (x)); + +%!assert <*52096> isempty (meta.class.fromName ("__nonexi$tent_cl@$$__")) +%!assert <*52096> isempty (meta.package.fromName ("__nonexi$tent_p@ck@ge__"))