17.02.14 01:27, Nick Coghlan написав(ла):
This change doesn't fix any of the known crashers in Lib/test/crashers, though - I applied the patch locally and checked.
It fixes other crasher (http://bugs.python.org/issue20440#msg209713).
The point is that people already know what Py_CLEAR does. This operation is like Py_CLEAR (the old reference is only removed *after* the pointer has been updated), except that the value it is being replaced with can be something other than NULL. If the replacement value *is* NULL, then the new operation is *exactly* equivalent to Py_CLEAR. Operations that do related things should ideally have related names. The point of my deliberately erroneous expansion is that it's an error a reader can make while still correctly understanding the *logic* of the code, even though they're missing a subtlety of the mechanics.
Py_CLEAR and Py_DECREF have no related names. I think that the clarity and briefness are important. I assume that these macros will be widely used (they allow existing code to write shorter), perhaps even more than Py_CLEAR. Therefore people will know what they do.
An explicit name like Py_SET_AND_DECREF would also be reasonable. It's substantially less confusing than Py_REPLACE, as it is less ambiguous about whether or not the refcount on the new value is adjusted.
I agree if it will satisfy Martin, although this name looks ugly to me. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com