Title: Unclear if exception should be set
Type: Stage:
Components: Documentation Versions: Python 3.1, Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jankratochvil, loewis
Priority: normal Keywords:

Created on 2010-10-09 18:01 by jankratochvil, last changed 2010-10-09 18:30 by jankratochvil. This issue is now closed.

Messages (3)
msg118281 - (view) Author: Jan Kratochvil (jankratochvil) Date: 2010-10-09 18:01
Return element [...] or NULL on failure.

Found element => return its pointer.
Found no element => return NULL (with no exception set).

But it is unclear whether the function can also:
Error happened => return NULL with an exception set.

It affects multiple versions of the doc, did not check which all.
msg118282 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-10-09 18:17
I find it quite clear. "failure" not only means that no item was found, but also that the operation failed, i.e. raised an exception. In general, a NULL pointer returned from a function that returns PyObject* *always* means that there is an exception. There is no need to repeat that every time.
msg118283 - (view) Author: Jan Kratochvil (jankratochvil) Date: 2010-10-09 18:30
OK, I am not used to Python, thanks.
Date User Action Args
2010-10-09 18:30:37jankratochvilsetstatus: open -> closed
resolution: not a bug
messages: + msg118283
2010-10-09 18:17:11loewissetnosy: + loewis
messages: + msg118282
2010-10-09 18:01:59jankratochvilcreate