@@ -401,6 +401,35 @@ class TestCustomBasicsizeSubclass(TestCustomBasicsize):
401
401
actual_basicsize = TestCustomBasicsizeSubclass .__basicsize__
402
402
assert expected_basicsize == actual_basicsize , "expected = %s, actual = %s" % (expected_basicsize , actual_basicsize )
403
403
404
+ def test_descrget (self ):
405
+ TestDescrGet = CPyExtType (
406
+ "TestDescrGet" ,
407
+ '''
408
+ PyObject* testdescr_get(PyObject* self, PyObject* obj, PyObject* type) {
409
+ if (obj == NULL) {
410
+ obj = Py_Ellipsis;
411
+ }
412
+ if (type == NULL) {
413
+ type = Py_Ellipsis;
414
+ }
415
+ return Py_BuildValue("OOO", self, obj, type);
416
+ }
417
+ ''' ,
418
+ tp_descr_get = "(descrgetfunc) testdescr_get" ,
419
+ )
420
+
421
+ descr = TestDescrGet ()
422
+
423
+ class Test :
424
+ getter = descr
425
+
426
+ obj = Test ()
427
+ # Using Ellipsis as a placeholder for C NULL
428
+ assert obj .getter == (descr , obj , Test )
429
+ assert Test .getter == (descr , ..., Test )
430
+ assert descr .__get__ (1 , int ) == (descr , 1 , int )
431
+ assert descr .__get__ (1 , None ) == (descr , 1 , ...)
432
+ assert descr .__get__ (None , int ) == (descr , ..., int )
404
433
405
434
def test_descrset (self ):
406
435
TestDescrSet = CPyExtType ("TestDescrSet" ,
0 commit comments