@@ -86,6 +86,40 @@ test_object(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
8686}
8787
8888
89+ static PyObject *
90+ test_py_is (PyObject * Py_UNUSED (module ), PyObject * Py_UNUSED (ignored ))
91+ {
92+ PyObject * o_none = Py_None ;
93+ PyObject * o_true = Py_True ;
94+ PyObject * o_false = Py_False ;
95+ PyObject * obj = PyList_New (0 );
96+ if (obj == NULL ) {
97+ return NULL ;
98+ }
99+
100+ /* test Py_Is() */
101+ assert (Py_Is (obj , obj ));
102+ assert (!Py_Is (obj , o_none ));
103+
104+ /* test Py_IsNone() */
105+ assert (Py_IsNone (o_none ));
106+ assert (!Py_IsNone (obj ));
107+
108+ /* test Py_IsTrue() */
109+ assert (Py_IsTrue (o_true ));
110+ assert (!Py_IsTrue (o_false ));
111+ assert (!Py_IsTrue (obj ));
112+
113+ /* testPy_IsFalse() */
114+ assert (Py_IsFalse (o_false ));
115+ assert (!Py_IsFalse (o_true ));
116+ assert (!Py_IsFalse (obj ));
117+
118+ Py_DECREF (obj );
119+ Py_RETURN_NONE ;
120+ }
121+
122+
89123static PyObject *
90124test_steal_ref (PyObject * Py_UNUSED (module ), PyObject * Py_UNUSED (ignored ))
91125{
@@ -358,6 +392,7 @@ test_module(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
358392
359393static struct PyMethodDef methods [] = {
360394 {"test_object" , test_object , METH_NOARGS , NULL },
395+ {"test_py_is" , test_py_is , METH_NOARGS , NULL },
361396 {"test_steal_ref" , test_steal_ref , METH_NOARGS , NULL },
362397#if !defined (PYPY_VERSION )
363398 {"test_frame" , test_frame , METH_NOARGS , NULL },
0 commit comments