Skip to content

Python.h contains intermingled declarations #81372

Description

@encukou
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']

    Activity

    1. encukou commented on Jun 7, 2019

      @encukou
      MemberAuthor

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

    2. encukou commented on Jun 7, 2019

      @encukou
      MemberAuthor

      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.

    3. vstinner commented on Jun 7, 2019

      @vstinner
      Member

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

    4. jdemeyer commented on Jun 7, 2019

      @jdemeyer
      Contributor

      Should we revert these inline functions back to macros?

    5. jdemeyer commented on Jun 7, 2019

      @jdemeyer
      Contributor

      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.

    6. lazka commented on Jun 7, 2019

      lazkamannequin
      Mannequin

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

    7. vstinner commented on Jun 7, 2019

      @vstinner
      Member

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

    8. vstinner commented on Jun 7, 2019

      @vstinner
      Member

      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.

    9. miss-islington commented on Jun 7, 2019

      @miss-islington
      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

    10. vstinner commented on Jun 7, 2019

      @vstinner
      Member

      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

    11. vstinner commented on Jun 13, 2019

      @vstinner
      Member

      Petr Viktorin fixed the issue, thanks ;-)

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions