py/objobject: Add object.__setattr__ function.

Allows assigning attributes on class instances that implement their own
__setattr__.  Both object.__setattr__ and super(A, b).__setattr__ will work
with this commit.
This commit is contained in:
Yonatan Goldschmidt
2019-12-09 18:31:35 +02:00
committed by Damien George
parent 90f286465b
commit 07ccb5588c
3 changed files with 50 additions and 2 deletions

View File

@@ -1038,9 +1038,11 @@ void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t
|| m_type == &mp_type_fun_builtin_1
|| m_type == &mp_type_fun_builtin_2
|| m_type == &mp_type_fun_builtin_3
|| m_type == &mp_type_fun_builtin_var)) {
|| m_type == &mp_type_fun_builtin_var)
&& type != &mp_type_object) {
// we extracted a builtin method without a first argument, so we must
// wrap this function in a type checker
// Note that object will do its own checking so shouldn't be wrapped.
dest[0] = mp_obj_new_checked_fun(type, member);
} else
#endif