@@ -2589,91 +2589,6 @@ test_set_type_size(PyObject *self, PyObject *Py_UNUSED(ignored))
25892589}
25902590
25912591
2592- // Test Py_CLEAR() macro
2593- static PyObject *
2594- test_py_clear (PyObject * self , PyObject * Py_UNUSED (ignored ))
2595- {
2596- // simple case with a variable
2597- PyObject * obj = PyList_New (0 );
2598- if (obj == NULL ) {
2599- return NULL ;
2600- }
2601- Py_CLEAR (obj );
2602- assert (obj == NULL );
2603-
2604- // gh-98724: complex case, Py_CLEAR() argument has a side effect
2605- PyObject * array [1 ];
2606- array [0 ] = PyList_New (0 );
2607- if (array [0 ] == NULL ) {
2608- return NULL ;
2609- }
2610-
2611- PyObject * * p = array ;
2612- Py_CLEAR (* p ++ );
2613- assert (array [0 ] == NULL );
2614- assert (p == array + 1 );
2615-
2616- Py_RETURN_NONE ;
2617- }
2618-
2619-
2620- // Test Py_SETREF() and Py_XSETREF() macros, similar to test_py_clear()
2621- static PyObject *
2622- test_py_setref (PyObject * self , PyObject * Py_UNUSED (ignored ))
2623- {
2624- // Py_SETREF() simple case with a variable
2625- PyObject * obj = PyList_New (0 );
2626- if (obj == NULL ) {
2627- return NULL ;
2628- }
2629- Py_SETREF (obj , NULL );
2630- assert (obj == NULL );
2631-
2632- // Py_XSETREF() simple case with a variable
2633- PyObject * obj2 = PyList_New (0 );
2634- if (obj2 == NULL ) {
2635- return NULL ;
2636- }
2637- Py_XSETREF (obj2 , NULL );
2638- assert (obj2 == NULL );
2639- // test Py_XSETREF() when the argument is NULL
2640- Py_XSETREF (obj2 , NULL );
2641- assert (obj2 == NULL );
2642-
2643- // gh-98724: complex case, Py_SETREF() argument has a side effect
2644- PyObject * array [1 ];
2645- array [0 ] = PyList_New (0 );
2646- if (array [0 ] == NULL ) {
2647- return NULL ;
2648- }
2649-
2650- PyObject * * p = array ;
2651- Py_SETREF (* p ++ , NULL );
2652- assert (array [0 ] == NULL );
2653- assert (p == array + 1 );
2654-
2655- // gh-98724: complex case, Py_XSETREF() argument has a side effect
2656- PyObject * array2 [1 ];
2657- array2 [0 ] = PyList_New (0 );
2658- if (array2 [0 ] == NULL ) {
2659- return NULL ;
2660- }
2661-
2662- PyObject * * p2 = array2 ;
2663- Py_XSETREF (* p2 ++ , NULL );
2664- assert (array2 [0 ] == NULL );
2665- assert (p2 == array2 + 1 );
2666-
2667- // test Py_XSETREF() when the argument is NULL
2668- p2 = array2 ;
2669- Py_XSETREF (* p2 ++ , NULL );
2670- assert (array2 [0 ] == NULL );
2671- assert (p2 == array2 + 1 );
2672-
2673- Py_RETURN_NONE ;
2674- }
2675-
2676-
26772592#define TEST_REFCOUNT () \
26782593 do { \
26792594 PyObject *obj = PyList_New(0); \
@@ -3337,8 +3252,6 @@ static PyMethodDef TestMethods[] = {
33373252 {"pynumber_tobase" , pynumber_tobase , METH_VARARGS },
33383253 {"without_gc" , without_gc , METH_O },
33393254 {"test_set_type_size" , test_set_type_size , METH_NOARGS },
3340- {"test_py_clear" , test_py_clear , METH_NOARGS },
3341- {"test_py_setref" , test_py_setref , METH_NOARGS },
33423255 {"test_refcount_macros" , test_refcount_macros , METH_NOARGS },
33433256 {"test_refcount_funcs" , test_refcount_funcs , METH_NOARGS },
33443257 {"test_py_is_macros" , test_py_is_macros , METH_NOARGS },
0 commit comments