Skip to content

Commit d6552e6

Browse files
author
Dilawar Singh
committed
1 parent 3ea0a66 commit d6552e6

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

pybind11/Finfo.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,42 +93,36 @@ py::object __Finfo__::getLookupValueFinfoItem(const ObjId& oid, const Finfo* f,
9393
string srcType = srcDestType[0];
9494
string tgtType = srcDestType[1];
9595

96-
py::object r;
96+
py::object r = py::none();
9797

9898
if (srcType == "string") {
9999
auto k = py::cast<string>(key);
100-
r = getLookupValueFinfoItemInner<string>(oid, f, k, tgtType);
100+
return getLookupValueFinfoItemInner<string>(oid, f, k, tgtType);
101101
} else if (srcType == "unsigned int") {
102102
auto k = py::cast<unsigned int>(key);
103-
r = getLookupValueFinfoItemInner<unsigned int>(oid, f, k, tgtType);
103+
return getLookupValueFinfoItemInner<unsigned int>(oid, f, k, tgtType);
104104
} else if (srcType == "ObjId") {
105105
auto k = py::cast<ObjId>(key);
106-
r = getLookupValueFinfoItemInner<ObjId>(oid, f, k, tgtType);
106+
return getLookupValueFinfoItemInner<ObjId>(oid, f, k, tgtType);
107107
} else if (srcType == "Id") {
108108
auto k = py::cast<Id>(key);
109-
r = getLookupValueFinfoItemInner<Id>(oid, f, k, tgtType);
109+
return getLookupValueFinfoItemInner<Id>(oid, f, k, tgtType);
110110
} else {
111-
r = py::none();
112-
}
113-
114-
if (r.is(py::none())) {
115111
py::print("getLookupValueFinfoItem::NotImplemented for key:", key,
116-
"srcType:", srcType, "and tgtType:", tgtType, "path: ",
117-
oid.path());
112+
"srcType:", srcType, "and tgtType:", tgtType, "path: ",
113+
oid.path());
118114
throw runtime_error("getLookupValueFinfoItem::NotImplemented error");
119115
}
120116
return r;
121117
}
122118

123119
py::object __Finfo__::getItem(const py::object& key)
124120
{
125-
py::print("Fetching value for", key, finfoType_);
126121
return func_(key);
127122
}
128123

129124
py::object __Finfo__::operator()(const py::object& key)
130125
{
131-
py::print("Calling function with key", key);
132126
return func_(key);
133127
}
134128

pybind11/Finfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class __Finfo__ {
4545

4646
py::print("Warning: Could not find", fname, "for key", key, "(type",
4747
tgtType, ") on path ", oid.path());
48+
throw py::key_error("Attribute error.");
4849
return py::none();
4950
}
5051

pybind11/pymoose.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ py::object getFieldGeneric(const ObjId &oid, const string &fieldName)
117117
auto finfo = cinfo->findFinfo(fieldName);
118118

119119
if (!finfo) {
120-
cout << "Error: " << fieldName << " is not found on " << oid.path()
121-
<< endl;
122-
return pybind11::none();
120+
throw py::key_error(fieldName + " is not found on '" + oid.path() + "'.");
123121
}
124122

125123
string finfoType = cinfo->getFinfoType(finfo);

0 commit comments

Comments
 (0)