Skip to content

Commit fdc4b6a

Browse files
committed
Fix: __setattr__ should not wrap tp_setattr, just tp_setattro
1 parent 327ed27 commit fdc4b6a

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9277,7 +9277,7 @@ static int type_ready_graalpy_slot_conv(PyTypeObject* cls) {
92779277
// NOTE: The slots may be called from managed code, i.e., we need to wrap the functions
92789278
// and convert arguments that should be C primitives.
92799279
// ADD_SLOT_CONV("__getattribute__", cls->tp_getattr, -2, JWRAPPER_GETATTR); tp_getattr does not have wrapper set in slotdefs and hence is ignored in add_operators
9280-
ADD_SLOT_CONV("__setattr__", cls->tp_setattr, -3, JWRAPPER_SETATTR);
9280+
// ADD_SLOT_CONV("__setattr__", cls->tp_setattr, -3, JWRAPPER_SETATTR); dtto for tp_setattr
92819281
ADD_SLOT_CONV("__repr__", cls->tp_repr, -1, JWRAPPER_REPR);
92829282
ADD_SLOT_CONV("__hash__", cls->tp_hash, -1, JWRAPPER_HASHFUNC);
92839283
ADD_SLOT_CONV("__call__", cls->tp_call, METH_KEYWORDS | METH_VARARGS, JWRAPPER_CALL);

scripts/slot_fuzzer.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ def test(fun, name):
7777
traceback.print_exc()
7878
else:
7979
print(type(e))
80-
81-
def test_dunder(obj, fun_name, *args):
82-
# avoid going through tp_getattr/o, which may be overridden to something funky
83-
args_str = ','.join([repr(x) for x in args])
84-
test(lambda: Klass.__dict__[fun_name](obj, *args), f"{fun_name} via class dict")
85-
test(lambda: getattr(obj, fun_name)(*args), f"{fun_name}")
8680
8781
def test_dunder(obj, fun_name, *args):
8882
# avoid going through tp_getattr/o, which may be overridden to something funky

0 commit comments

Comments
 (0)