File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
graalpython/com.oracle.graal.python.test/src/tests/cpyext Expand file tree Collapse file tree 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):
4848
4949class TestDescrObject (object ):
5050
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
5176
5277 def test_new_descr (self ):
5378 C = CPyExtType ("C_" ,
You can’t perform that action at this time.
0 commit comments