classification
Title: "SystemError: bad call flags" exceptions added as part of BPO-33012 are difficult to debug
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ngie, vstinner
Priority: normal Keywords: patch

Created on 2020-03-07 04:11 by ngie, last changed 2020-03-12 12:38 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18944 merged vstinner, 2020-03-11 23:29
PR 18956 merged vstinner, 2020-03-12 07:39
PR 18957 merged vstinner, 2020-03-12 07:47
Messages (5)
msg363575 - (view) Author: Enji Cooper (ngie) * Date: 2020-03-07 04:11
When a body of C extensions needs to be ported from python <3.8 to 3.8, one of the issues one might run into is improperly defined methods in a C extension, which results in SystemErrors stating:

>>> SystemError: bad call flags

This new behavior was added as part of Issue # 33012.

While the issues definitely need to be resolved in the C extensions, where to start is not completely clear. I had to put `printfs` in PyCFunction_NewEx and PyDescr_NewMethod to track down the issues, e.g.,

>>> printf("method name: %s\n", method->ml_name);

While this might be misleading for duplicate method definitions, it definitely helps narrow down the offending code.

Adding the method name to the SystemError would be a big step in the right direction in terms of making it easier to resolve these issues.

PS I realize that this might be masked by casting PyCFunction on methods or by not using gcc 8+, but I'd argue that C extensions need to have developer issues like this be clearer to the end-reader.
msg364000 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-12 07:38
New changeset c7d2d69d95b263ee5f83511bc6fbe53acdc24ea3 by Victor Stinner in branch 'master':
bpo-39884: Add method name in "bad call flags" error (GH-18944)
https://github.com/python/cpython/commit/c7d2d69d95b263ee5f83511bc6fbe53acdc24ea3
msg364012 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-12 12:37
New changeset 03ac090c5f8d5b281e56c5f5431c1754fd4efe5c by Victor Stinner in branch '3.8':
bpo-39884: Add method name in "bad call flags" error (GH-18944) (GH-18956)
https://github.com/python/cpython/commit/03ac090c5f8d5b281e56c5f5431c1754fd4efe5c
msg364013 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-12 12:37
New changeset 6a12676b1910d52c85561bdf4f1e20aa13fc8f46 by Victor Stinner in branch '3.7':
bpo-39884: Add method name in "bad call flags" error (GH-18944) (GH-18957)
https://github.com/python/cpython/commit/6a12676b1910d52c85561bdf4f1e20aa13fc8f46
msg364014 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-03-12 12:38
> While the issues definitely need to be resolved in the C extensions, where to start is not completely clear. I had to put `printfs` in PyCFunction_NewEx and PyDescr_NewMethod to track down the issues, e.g., (...)

I agree, I had the same issue :-) I fixed the issue in 3.7, 3.8 and master branches.

In 3.7, the modified functions are different and the error message was different but similar.

Thanks for your bug report ;-)
History
Date User Action Args
2020-03-12 12:38:29vstinnersetstatus: open -> closed
versions: + Python 3.7, Python 3.9
messages: + msg364014

resolution: fixed
stage: patch review -> resolved
2020-03-12 12:37:25vstinnersetmessages: + msg364013
2020-03-12 12:37:25vstinnersetmessages: + msg364012
2020-03-12 07:47:00vstinnersetpull_requests: + pull_request18308
2020-03-12 07:39:24vstinnersetpull_requests: + pull_request18307
2020-03-12 07:38:15vstinnersetmessages: + msg364000
2020-03-11 23:29:16vstinnersetkeywords: + patch
nosy: + vstinner

pull_requests: + pull_request18298
stage: patch review
2020-03-07 04:11:33ngiecreate