Skip to content

Commit aafa6f1

Browse files
committed
getset setters return 0 on success, -1 on failure
1 parent 014c7ec commit aafa6f1

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ typedef PyObject* (*f20)(PyObject*, PyObject*, PyObject*, PyObject*, PyObject*,
465465
#define _CALL_ARITY(FUN, ...) ( (_PICK_FUN_CAST(NULL, ##__VA_ARGS__, f20, f19, f18, f17, f16, f15, f14, f13, f12, f11, f10, f9, f8, f7, f6, f5, f4, f3, f2, f1, f0))(FUN))(__VA_ARGS__)
466466
#define ARG(__n) explicit_cast((PyObject*)polyglot_get_arg((__n)))
467467

468+
int wrap_setter(PyCFunction fun, PyObject* self, PyObject* value, PyObject* closure) {
469+
return _CALL_ARITY(fun, ARG(1), ARG(2), ARG(3));
470+
}
471+
468472
void* wrap_direct(PyCFunction fun, ...) {
469473
PyObject *res = NULL;
470474
switch(polyglot_get_arg_count()-1) {

graalpython/com.oracle.graal.python.cext/src/capi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ void initialize_hashes();
110110

111111
// prototype of C landing function
112112
void* wrap_direct(PyCFunction fun, ...);
113+
int wrap_setter(PyCFunction fun, PyObject *self, PyObject *value, PyObject *closure);
113114
void* wrap_varargs(PyCFunction fun, PyObject *module, PyObject *varargs);
114115
void* wrap_keywords(PyCFunctionWithKeywords fun, PyObject *module, PyObject *varargs, PyObject *kwargs);
115116
void* wrap_noargs(PyCFunction fun, PyObject *module, PyObject *pnone);

graalpython/com.oracle.graal.python.cext/src/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ int PyType_Ready(PyTypeObject* cls) {
333333
getter_fun != NULL ? getter_fun : to_java(Py_None),
334334
wrap_direct,
335335
setter_fun != NULL ? setter_fun : to_java(Py_None),
336-
wrap_direct,
336+
wrap_setter,
337337
getset.doc ? truffle_read_string(getset.doc) : truffle_read_string(""),
338338
// do not convert the closure, it is handed to the
339339
// getter and setter as-is

graalpython/lib-graalpython/python_cext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,9 @@ def member_getter(self):
679679
if setter:
680680
setter_w = CreateFunction(name, setter, setter_wrapper)
681681
def member_setter(self, value):
682-
setter_w(self, value, closure)
682+
result = setter_w(self, value, closure)
683+
if result != 0:
684+
raise
683685
return None
684686
getset.setter(member_setter)
685687
else:

0 commit comments

Comments
 (0)