File tree 1 file changed +25
-0
lines changed
graalpython/com.oracle.graal.python.test/src/tests/cpyext
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,31 @@ def _reference_classmethod(args):
48
48
49
49
class TestDescrObject (object ):
50
50
51
+ def test_new_classmethod (self ):
52
+
53
+ TestNewClassMethod = CPyExtType ("TestNewClassMethod" ,
54
+ """
55
+ static PyObject * c_void_p_from_param(PyObject *self, PyObject *value) {
56
+ /* just returns self which should be the class */
57
+ return self;
58
+ }
59
+ static PyMethodDef c_void_p_method = { "from_param", c_void_p_from_param, METH_O };
60
+ """ ,
61
+ post_ready_code = """
62
+ PyObject *meth = PyDescr_NewClassMethod(&TestNewClassMethodType, &c_void_p_method);
63
+ if (!meth) {
64
+ return NULL;
65
+ }
66
+ int x = PyDict_SetItemString(TestNewClassMethodType.tp_dict, c_void_p_method.ml_name, meth);
67
+ Py_DECREF(meth);
68
+ if (x == -1) {
69
+ return NULL;
70
+ }
71
+ """ ,
72
+ )
73
+
74
+ tester = TestNewClassMethod ()
75
+ assert tester .from_param (123 ) == TestNewClassMethod
51
76
52
77
def test_new_descr (self ):
53
78
C = CPyExtType ("C_" ,
You can’t perform that action at this time.
0 commit comments