gh-98724: Fix Py_CLEAR() macro side effects (#99100) (#99288)

The Py_CLEAR(), Py_SETREF() and Py_XSETREF() macros now only evaluate
their argument once. If an argument has side effects, these side
effects are no longer duplicated.

Add test_py_clear() and test_py_setref() unit tests to _testcapi.

(cherry picked from commit c03e05c2e72f3ea5e797389e7d1042eef85ad37a)
4 files changed