<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 12, 2013 at 5:10 AM, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hello,<br>
<br>
It seems NULL is allowed as the first argument of PyErr_Format,<br>
PyErr_SetString and PyErr_SetObject. Moreover, it means "clear the<br>
error indicator". However, this is not mentioned in the docs. I was<br>
wondering if we should officialize this behaviour or change it.<br></blockquote></div><br></div><div class="gmail_extra">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:<br>
<br></div><div class="gmail_extra">1. Document that NULL is not allowed in PyErr_Set{Object|String}<br></div><div class="gmail_extra">2. Switch all actual uses of that idiom in the stdlib to PyError_Clear<br><br></div><div class="gmail_extra">
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.<br>
<br></div><div class="gmail_extra">Eli<br></div><div class="gmail_extra"><br><br></div></div>