hochl

Results 8 comments of hochl

I have some suggestion for the test: It should crash with the old `Py_CLEAR` version so you do not get any regressions.

I think all macros should be changed so they only reference their arguments once. This avoids the whole issue with side effects applied multiple times.

[Doc/c-api/refcounting.rst](https://github.com/python/cpython/commit/deb652fef785f644e25a007d987017428bc9655f#diff-dc2560f4ad15f1a7f4e0b38790853e73179c06a6720438fb94c4152ee83992c8) contains two times an error: _If the argument has side effects, there are no longer duplicated._ Further down it is correct with _these are no longer duplicated_.

I am not sure that I made the point totally clear. Here is an example program for clarification, using some dummy type for `PyObject`. ``` #include #define _PyObject_CAST(op) ((PyObject*)(op)) #define...

How about this macro? ``` #define Py_CLEAR(op) \ do { \ PyObject **_py_tmp = (PyObject**)&(op); \ if (*_py_tmp != NULL) { \ PyObject* _py_tmp2 = *_py_tmp; \ *_py_tmp = NULL;...

Perfect! The main problem I have with macros that pretend to be functions is that they might evaluate their arguments several times, and this is totally unexpected. I hope the...

I think this should be extended to all macros, so that they only reference their arguments once. If that can be done it could be made public that from now...

I am not entirely sure if reverting the change is the way to go. As I see it there is a more fundamental type punning problem here where this macro...