original) (raw)
(On Mon, Aug 12, 2013 at 5:10 AM, Antoine Pitrou <solipsis@pitrou.net> wrote:
Hello,
It seems NULL is allowed as the first argument of PyErr\_Format,
PyErr\_SetString and PyErr\_SetObject. Moreover, it means "clear the
error indicator". However, this is not mentioned in the docs. I was
wondering if we should officialize this behaviour or change it.
Since the same capability is available much more clearly through PyError\_Clear (and also through PyError\_Restore(NULL, NULL, NULL)), IMHO we should at least:
1. Document that NULL is not allowed in PyErr_Set{Object|String}
2. Switch all actual uses of that idiom in the stdlib to PyError_Clear
If we don't fear external code breakaga that relies on this undocumented behavior, we can also add explicit treating of NULL in PyErr_Set{Object|String} (maybe even asserting). Otherwise, we can just keep the behavior as is for now, though make it more correct: to do the reset it would call PyError_Restore(NULL, value, tb) even though PyError_Restore documents that all args should be NULL to actually clear the indicator.
Eli