Skip to content

Commit 116f600

Browse files
Merge pull request #224 from Distributive-Network/philippe/fix/58
Philippe/fix/58
2 parents aad51c4 + c1beb35 commit 116f600

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

src/JSArrayProxy.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,17 @@ PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_get(JSArrayProxy *self, Py
6060
// look through the methods for dispatch and return key if no method found
6161
for (size_t index = 0;; index++) {
6262
const char *methodName = JSArrayProxyType.tp_methods[index].ml_name;
63-
if (methodName == NULL) { // reached end of list
63+
if (methodName == NULL || !PyUnicode_Check(key)) { // reached end of list
6464
JS::RootedValue *value = new JS::RootedValue(GLOBAL_CX);
6565
JS_GetPropertyById(GLOBAL_CX, self->jsArray, id, value);
66-
JS::RootedObject *global = new JS::RootedObject(GLOBAL_CX, JS::GetNonCCWObjectGlobal(self->jsArray));
67-
return pyTypeFactory(GLOBAL_CX, global, value)->getPyObject();
66+
JS::RootedObject *thisObj = new JS::RootedObject(GLOBAL_CX, self->jsArray);
67+
return pyTypeFactory(GLOBAL_CX, thisObj, value)->getPyObject();
6868
}
69-
else if (PyUnicode_Check(key)) {
69+
else {
7070
if (strcmp(methodName, PyUnicode_AsUTF8(key)) == 0) {
7171
return PyObject_GenericGetAttr((PyObject *)self, key);
7272
}
7373
}
74-
else {
75-
JS::RootedValue *value = new JS::RootedValue(GLOBAL_CX);
76-
JS_GetPropertyById(GLOBAL_CX, self->jsArray, id, value);
77-
JS::RootedObject *global = new JS::RootedObject(GLOBAL_CX, JS::GetNonCCWObjectGlobal(self->jsArray));
78-
return pyTypeFactory(GLOBAL_CX, global, value)->getPyObject();
79-
}
8074
}
8175
}
8276

src/JSObjectProxy.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,17 @@ PyObject *JSObjectProxyMethodDefinitions::JSObjectProxy_get(JSObjectProxy *self,
8989
// look through the methods for dispatch
9090
for (size_t index = 0;; index++) {
9191
const char *methodName = JSObjectProxyType.tp_methods[index].ml_name;
92-
if (methodName == NULL) { // reached end of list
92+
if (methodName == NULL || !PyUnicode_Check(key)) {
9393
JS::RootedValue *value = new JS::RootedValue(GLOBAL_CX);
9494
JS_GetPropertyById(GLOBAL_CX, self->jsObject, id, value);
95-
JS::RootedObject *global = new JS::RootedObject(GLOBAL_CX, JS::GetNonCCWObjectGlobal(self->jsObject));
96-
return pyTypeFactory(GLOBAL_CX, global, value)->getPyObject();
95+
JS::RootedObject *thisObj = new JS::RootedObject(GLOBAL_CX, self->jsObject);
96+
return pyTypeFactory(GLOBAL_CX, thisObj, value)->getPyObject();
9797
}
98-
else if (PyUnicode_Check(key)) {
98+
else {
9999
if (strcmp(methodName, PyUnicode_AsUTF8(key)) == 0) {
100100
return PyObject_GenericGetAttr((PyObject *)self, key);
101101
}
102102
}
103-
else {
104-
JS::RootedValue *value = new JS::RootedValue(GLOBAL_CX);
105-
JS_GetPropertyById(GLOBAL_CX, self->jsObject, id, value);
106-
JS::RootedObject *global = new JS::RootedObject(GLOBAL_CX, JS::GetNonCCWObjectGlobal(self->jsObject));
107-
108-
return pyTypeFactory(GLOBAL_CX, global, value)->getPyObject();
109-
}
110103
}
111104
}
112105

0 commit comments

Comments
 (0)