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 2016-02-11 11:33 by serhiy.storchaka. 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
2016-02-11 11:33:18serhiy.storchakasetstatus: open -> closed
messages: + msg260090

assignee: serhiy.storchaka
resolution: fixed
stage: commit review -> resolved
2016-02-11 10:42:20python-devsetnosy: + python-dev
messages: + msg260084
2016-02-11 10:23:24serhiy.storchakasetmessages: + msg260083
2016-02-11 01:18:44vstinnersetmessages: + msg260064
2016-02-10 23:30:29Jim.Jewettsetnosy: + Jim.Jewett

messages: + msg260059
stage: patch review -> commit review
2016-02-10 22:29:47vstinnersetnosy: + vstinner
messages: + msg260049
2016-02-09 06:46:58martin.pantersetnosy: + martin.panter
messages: + msg259916
2016-02-08 19:39:33serhiy.storchakacreate