[Python-Dev] NULL allowed in PyErr_SetString and friends? (original) (raw)
Eli Bendersky eliben at gmail.com
Mon Aug 12 15:01:57 CEST 2013
- Previous message: [Python-Dev] NULL allowed in PyErr_SetString and friends?
- Next message: [Python-Dev] SSL issues in Python stdlib and 3rd party code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Aug 12, 2013 at 5:10 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
Hello, It seems NULL is allowed as the first argument of PyErrFormat, PyErrSetString and PyErrSetObject. 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:
- Document that NULL is not allowed in PyErr_Set{Object|String}
- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130812/8576c295/attachment.html>
- Previous message: [Python-Dev] NULL allowed in PyErr_SetString and friends?
- Next message: [Python-Dev] SSL issues in Python stdlib and 3rd party code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]