-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for __getattr__ (#36) #37
base: master
Are you sure you want to change the base?
Conversation
You're using the deprecated name, use And your signature is wrong. The signature documented here conflicts with here. The question is resolved by the cpython header, where an |
Gotcha, I'll give it another look. Thanks for the quick answer! |
Even after changing the name and signature, I get the same error. Is it possible that there's not a good way to implement |
No. You should return a ('tp_str', ctypes.CFUNCTYPE(PyObject_p, PyObject_p)),
('tp_getattro', ctypes.CFUNCTYPE(PyObject_p, PyObject_p, PyObject_p)),
('tp_setattro', ctypes.CFUNCTYPE(ctypes.c_int, PyObject_p, PyObject_p, PyObject_p)),
('tp_as_buffer', ctypes.c_void_p),
('tp_flags', ctypes.c_ulong),
# ... |
Right, I changed the signature. My point was that when I would like to override |
I got the same errors @stevenfontanella mentioned with c_int, but I found that @ctypes.CFUNCTYPE(ctypes.c_char_p, PyObject_p, PyObject_p, PyObject_p)
def dict_setattr_cfunc(dict, field, val):
dict[field] = val;
tp_func_dict[(dict, "__setattr__")] = dict_setattr_cfunc;
PyTypeObject.from_address(id(dict)).tp_setattro = dict_setattr_cfunc; |
I was working on __setattr__ as well, but for some reason I get
when I run the following test:
The code I added for that was: