This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unclear if exception should be set
Type: Stage:
Components: Documentation Versions: Python 3.1, Python 2.7
process
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 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg118281 - (view) Author: Jan Kratochvil (jankratochvil) Date: 2010-10-09 18:01
http://docs.python.org/py3k/c-api/object.html
PyObject_GetItem
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.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54266
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