classification
Title: Python.h contains intermingled declarations
Type: Stage: resolved
Components: Versions: Python 3.9, Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jdemeyer, lazka, lukasz.langa, miss-islington, petr.viktorin, vstinner
Priority: normal Keywords: patch

Created on 2019-06-07 09:13 by petr.viktorin, last changed 2019-06-13 01:05 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13887 merged petr.viktorin, 2019-06-07 09:20
PR 13892 merged vstinner, 2019-06-07 12:45
PR 13897 merged miss-islington, 2019-06-07 15:52
Messages (11)
msg344912 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2019-06-07 09:13
When compiled with GCC's -Werror=declaration-after-statement ("intermingled declarations" in PEP7), cpython/abstract.h (included from <Python.h>) errors on vectorcall helper functions added in 3.8.0 Beta 1.

It's well within our rights to ignore this: since 3.6 we require intermingled declarations.
But, when re-compiling Fedora we've seen several projects fail with this warning (so far: pygobject3, python-dbus, xen; more will likely come).

Dear Release Manager, should we patch 3.8 to avoid this? The patch is simple, and it would give projects that we(re) dutifully tested with the Alphas one more release to adapt.

I don't think it's worth changing for 3.9 (but if we do we should test it).
msg344914 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2019-06-07 09:27
> pygobject3, python-dbus, xen

Correction:
- The Fedora packages failed to build; this might or might not be due to the projects themseves
- pygobject3 actually only warns on this

Anyway, we can usually take care of open-source stuff. Only take it as a litmus test for codebases we don't know about.
msg344928 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-07 11:55
PR 13887 is fine but I would prefer to still be able to use C99 style for variable declarations. More generally, I don't think that variable declaration is the only issue: static inline function is a new shiny thing which can cause other issues with some C compilers. So I propose a different approach, bpo-37194: "Move new vector private declarations to the internal C API".
msg344931 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-06-07 12:26
Should we revert these inline functions back to macros?
msg344932 - (view) Author: Jeroen Demeyer (jdemeyer) * (Python triager) Date: 2019-06-07 12:29
> It's well within our rights to ignore this: since 3.6 we require intermingled declarations.

It's not clear from PEP 7 if we require intermingled declarations only when compiling CPython itself, or also for external packages that include CPython headers. It would be prudent to stay C89-compatible for non-internal header files.
msg344951 - (view) Author: Christoph Reiter (lazka) * Date: 2019-06-07 15:34
I've removed -Wdeclaration-after-statement in upstream pygobject: https://gitlab.gnome.org/GNOME/pygobject/merge_requests/119
msg344955 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-07 15:51
New changeset 740a84de73ad8d02655de0a084036f4b7e49a01b by Victor Stinner in branch 'master':
bpo-37191: Move TestPEP590 from test_capi to test_call (GH-13892)
https://github.com/python/cpython/commit/740a84de73ad8d02655de0a084036f4b7e49a01b
msg344957 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-07 15:59
> I've removed -Wdeclaration-after-statement in upstream pygobject: https://gitlab.gnome.org/GNOME/pygobject/merge_requests/119

Thanks! Enjoy C99! :-) IMHO C99 with variables in the middle of a function helps to write more reliable code: we better control the scope of a variable. It reduces the risk of using an uninitialized variable.
msg344959 - (view) Author: miss-islington (miss-islington) Date: 2019-06-07 16:13
New changeset 5effd10bf14ab0a8a6695100aaf0b687eca68e6d by Miss Islington (bot) in branch '3.8':
bpo-37191: Move TestPEP590 from test_capi to test_call (GH-13892)
https://github.com/python/cpython/commit/5effd10bf14ab0a8a6695100aaf0b687eca68e6d
msg344965 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-07 16:32
New changeset 9689f80e61e5863668a562793ebb85031ef9fd3e by Victor Stinner (Petr Viktorin) in branch '3.8':
bpo-37191: Avoid declaration-after-statement in header included from Python.h (GH-13887)
https://github.com/python/cpython/commit/9689f80e61e5863668a562793ebb85031ef9fd3e
msg345442 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-06-13 01:05
Petr Viktorin fixed the issue, thanks ;-)
History
Date User Action Args
2019-06-13 01:05:17vstinnersetstatus: open -> closed
versions: + Python 3.9
messages: + msg345442

resolution: fixed
stage: patch review -> resolved
2019-06-07 16:32:00vstinnersetmessages: + msg344965
2019-06-07 16:13:19miss-islingtonsetnosy: + miss-islington
messages: + msg344959
2019-06-07 15:59:04vstinnersetmessages: + msg344957
2019-06-07 15:52:42miss-islingtonsetpull_requests: + pull_request13772
2019-06-07 15:51:34vstinnersetmessages: + msg344955
2019-06-07 15:34:12lazkasetnosy: + lazka
messages: + msg344951
2019-06-07 12:45:12vstinnersetstage: patch review
pull_requests: + pull_request13766
2019-06-07 12:29:15jdemeyersetmessages: + msg344932
2019-06-07 12:26:29jdemeyersetnosy: + jdemeyer
messages: + msg344931
2019-06-07 11:55:29vstinnersetnosy: + vstinner
messages: + msg344928
2019-06-07 09:27:03petr.viktorinsetmessages: + msg344914
stage: patch review -> (no value)
2019-06-07 09:20:28petr.viktorinsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13761
2019-06-07 09:13:57petr.viktorincreate