From f3e52c6e04cb90b2ff2d6f76d7e3441aadf99cb3 Mon Sep 17 00:00:00 2001 From: Alex Siryi Date: Tue, 14 Feb 2017 13:36:08 +0200 Subject: [PATCH] Fixed children retrieving from python collections by javascript. If python collection had a method with a name of the item that was requested, such method reference returned instead. --- src/Wrapper.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Wrapper.cpp b/src/Wrapper.cpp index e3d318e..c8bdaee 100644 --- a/src/Wrapper.cpp +++ b/src/Wrapper.cpp @@ -273,6 +273,14 @@ void CPythonObject::NamedGetter(v8::Local prop, const v8::PropertyCa if (PyGen_Check(obj.ptr())) CALLBACK_RETURN(v8::Undefined(info.GetIsolate())); + if (::PyMapping_Check(obj.ptr()) && + ::PyMapping_HasKeyString(obj.ptr(), *name)) + { + py::object result(py::handle<>(::PyMapping_GetItemString(obj.ptr(), *name))); + + if (!result.is_none()) CALLBACK_RETURN(Wrap(result)); + } + PyObject *value = ::PyObject_GetAttrString(obj.ptr(), *name); if (!value) @@ -288,15 +296,7 @@ void CPythonObject::NamedGetter(v8::Local prop, const v8::PropertyCa py::throw_error_already_set(); } } - - if (::PyMapping_Check(obj.ptr()) && - ::PyMapping_HasKeyString(obj.ptr(), *name)) - { - py::object result(py::handle<>(::PyMapping_GetItemString(obj.ptr(), *name))); - - if (!result.is_none()) CALLBACK_RETURN(Wrap(result)); - } - + CALLBACK_RETURN(v8::Handle()); }