Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Subclass-ability #10

Closed
teodoryantcheff opened this issue Sep 14, 2014 · 0 comments
Closed

Subclass-ability #10

teodoryantcheff opened this issue Sep 14, 2014 · 0 comments

Comments

@teodoryantcheff
Copy link

Playing around with your module I wanted to create a subclass of the SpiDev class, but found it impossible. After some poking around Python docs I added a Py_TPFLAGS_BASETYPE flag and all seems to be fine and my app works. Not sure is that's all that needs to be done ...
Since it's only a one line change, didn't want to create a full blown pull request so here's the diff :

diff --git a/spidev_module.c b/spidev_module.c
index f39a761..c9413aa 100644
--- a/spidev_module.c
+++ b/spidev_module.c
@@ -798,7 +798,7 @@ static PyTypeObject SpiDevObjectType = {
        0,                              /* tp_getattro */
        0,                              /* tp_setattro */
        0,                              /* tp_as_buffer */
-       Py_TPFLAGS_DEFAULT,             /* tp_flags */
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,               /* tp_flags */
        SpiDevObjectType_doc,           /* tp_doc */
        0,                              /* tp_traverse */
        0,                              /* tp_clear */

Please let me know if you see merging this into master as a workable idea. Thanks !

Cheers,

Teo

Gadgetoid added a commit to Gadgetoid/py-spidev that referenced this issue Jan 30, 2015
@doceme doceme closed this as completed Jul 29, 2015
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants