Issue 26312: Raise SystemError on programmical errors in PyArg_Parse*() (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/70500

classification

Title: Raise SystemError on programmical errors in PyArg_Parse*()
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.6

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Jim.Jewett, martin.panter, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016-02-08 19:39 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pyarg_parse_error.patch serhiy.storchaka,2016-02-08 19:39 review
Messages (8)
msg259877 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-08 19:39
For now programmical errors with the use of PyArg_ParseTuple() cause raising SystemError. But some programmical errors with the use of PyArg_ParseTupleAndKeywords() cause raising RuntimeError. I think that SystemError is the correct exception type. Proposed patch replaces RuntimeError with SystemError in PyArg_ParseTupleAndKeywords(). This change shouldn't break any code (except CPython tests for PyArg_ParseTupleAndKeywords()), because this exception never raised if PyArg_Parse*() functions are used correctly.
msg259916 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-02-09 06:46
Seems like a reasonable change and patch to me.
msg260049 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-02-10 22:29
Yeah, I also expect SystemError from C functions (of the Python C API) badly used. RuntimeError is more used in programming bugs at Python level. pyarg_parse_error.patch LGTM.
msg260059 - (view) Author: Jim Jewett (Jim.Jewett) * (Python triager) Date: 2016-02-10 23:30
It feels a bit odd to say that I've performed a triage review given the three people already involved -- but I did, and I think it is ready to commit. I believe it is a bug fix, but too subtle a bug to justify backporting. The only question is whether there should be a "What's New?" entry for the change.
msg260064 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-02-11 01:18
> The only question is whether there should be a "What's New?" entry for the change. I don't think so. It's low level and nobody should see this exception anyway :-) It's an obvious bug in a C extension.
msg260083 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-11 10:23
SystemError is not new exception. It could be raised on other programming bugs. In any case I doesn't expect that anybody catches such exceptions.
msg260084 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-02-11 10:42
New changeset c7eff18f3840 by Serhiy Storchaka in branch 'default': Issue #26312: SystemError is now raised in all programming bugs with using https://hg.python.org/cpython/rev/c7eff18f3840
msg260090 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-11 11:33
Thanks for your review.
History
Date User Action Args
2022-04-11 14:58:27 admin set github: 70500
2016-02-11 11:33:18 serhiy.storchaka set status: open -> closedmessages: + assignee: serhiy.storchakaresolution: fixedstage: commit review -> resolved
2016-02-11 10:42:20 python-dev set nosy: + python-devmessages: +
2016-02-11 10:23:24 serhiy.storchaka set messages: +
2016-02-11 01🔞44 vstinner set messages: +
2016-02-10 23:30:29 Jim.Jewett set nosy: + Jim.Jewettmessages: + stage: patch review -> commit review
2016-02-10 22:29:47 vstinner set nosy: + vstinnermessages: +
2016-02-09 06:46:58 martin.panter set nosy: + martin.pantermessages: +
2016-02-08 19:39:33 serhiy.storchaka create