Add tests for using PEP560 with classes implemented in C.#4883
Conversation
| return -1; | ||
| } | ||
|
|
||
| o->item = item; |
There was a problem hiding this comment.
Is there a DECREF missing here? PyArg_UnpackTuple returns a borrowed item. Also there might be a value already here so a DECREF would also be needed (before the assignment). Unless I misunderstand something (totally possible, I feel very rusty in this area :-).
There was a problem hiding this comment.
I think Py_INCREF(item) is needed.
There was a problem hiding this comment.
But for the purposes of this test we should be able to just remove this function and tp_init slot.
| } PyGenericObject; | ||
|
|
||
|
|
||
| /* Test PEP 560 slots */ |
dbd76c7 to
e5c51fe
Compare
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thank you for adding these tests! I just have one suggestion to make the test closer to how these methods will be used in typical code. The idea is that there will be typically a pair of classes:
class Generic:
def __class_getitem__(cls, item):
return GenericAlias(item)
class GenericAlias:
def __init__(self, item):
self.item = item
def __mro_entries__(self, bases):
return (item,)but this is just a minor suggestion, you can merge it as is if you prefer.
|
Thanks! (If we agree to change |
Based on tests from #4878.