Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python.h contains intermingled declarations #81372

Closed
encukou opened this issue Jun 7, 2019 · 11 comments
Closed

Python.h contains intermingled declarations #81372

encukou opened this issue Jun 7, 2019 · 11 comments
Labels
3.8 only security fixes 3.9 only security fixes

Comments

@encukou
Copy link
Member

encukou commented Jun 7, 2019

BPO 37191
Nosy @vstinner, @encukou, @ambv, @jdemeyer, @lazka, @miss-islington
PRs
  • [3.8] bpo-37191: Avoid declaration-after-statement in header included from Python.h #13887
  • bpo-37191: Move PEP 590 vectorcall tests #13892
  • [3.8] bpo-37191: Move TestPEP590 from test_capi to test_call (GH-13892) #13897
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-06-13.01:05:17.723>
    created_at = <Date 2019-06-07.09:13:57.171>
    labels = ['3.8', '3.9']
    title = 'Python.h contains intermingled declarations'
    updated_at = <Date 2019-06-13.01:05:17.717>
    user = 'https://github.com/encukou'

    bugs.python.org fields:

    activity = <Date 2019-06-13.01:05:17.717>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-13.01:05:17.723>
    closer = 'vstinner'
    components = []
    creation = <Date 2019-06-07.09:13:57.171>
    creator = 'petr.viktorin'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37191
    keywords = ['patch']
    message_count = 11.0
    messages = ['344912', '344914', '344928', '344931', '344932', '344951', '344955', '344957', '344959', '344965', '345442']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'petr.viktorin', 'lukasz.langa', 'jdemeyer', 'lazka', 'miss-islington']
    pr_nums = ['13887', '13892', '13897']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37191'
    versions = ['Python 3.8', 'Python 3.9']

    @encukou
    Copy link
    Member Author

    encukou commented Jun 7, 2019

    When compiled with GCC's -Werror=declaration-after-statement ("intermingled declarations" in PEP-7), 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).

    @encukou encukou added the 3.8 only security fixes label Jun 7, 2019
    @encukou
    Copy link
    Member Author

    encukou commented Jun 7, 2019

    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.

    @vstinner
    Copy link
    Member

    vstinner commented Jun 7, 2019

    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".

    @jdemeyer
    Copy link
    Contributor

    jdemeyer commented Jun 7, 2019

    Should we revert these inline functions back to macros?

    @jdemeyer
    Copy link
    Contributor

    jdemeyer commented Jun 7, 2019

    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.

    @lazka
    Copy link
    Mannequin

    lazka mannequin commented Jun 7, 2019

    I've removed -Wdeclaration-after-statement in upstream pygobject: https://gitlab.gnome.org/GNOME/pygobject/merge_requests/119

    @vstinner
    Copy link
    Member

    vstinner commented Jun 7, 2019

    New changeset 740a84d by Victor Stinner in branch 'master':
    bpo-37191: Move TestPEP590 from test_capi to test_call (GH-13892)
    740a84d

    @vstinner
    Copy link
    Member

    vstinner commented Jun 7, 2019

    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.

    @miss-islington
    Copy link
    Contributor

    New changeset 5effd10 by Miss Islington (bot) in branch '3.8':
    bpo-37191: Move TestPEP590 from test_capi to test_call (GH-13892)
    5effd10

    @vstinner
    Copy link
    Member

    vstinner commented Jun 7, 2019

    New changeset 9689f80 by Victor Stinner (Petr Viktorin) in branch '3.8':
    bpo-37191: Avoid declaration-after-statement in header included from Python.h (GH-13887)
    9689f80

    @vstinner
    Copy link
    Member

    Petr Viktorin fixed the issue, thanks ;-)

    @vstinner vstinner added the 3.9 only security fixes label Jun 13, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants