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

cpython/abstract.h not compatible with C90 #83796

Closed
petere mannequin opened this issue Feb 12, 2020 · 7 comments
Closed

cpython/abstract.h not compatible with C90 #83796

petere mannequin opened this issue Feb 12, 2020 · 7 comments
Labels
3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@petere
Copy link
Mannequin

petere mannequin commented Feb 12, 2020

BPO 39615
Nosy @ericvsmith, @benjaminp, @petere, @serhiy-storchaka
PRs
  • bpo-39615: Make cpython/abstract.h compatible with C90 #18481
  • 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 2020-02-13.02:00:28.910>
    created_at = <Date 2020-02-12.11:55:07.068>
    labels = ['interpreter-core', 'invalid', '3.9']
    title = 'cpython/abstract.h not compatible with C90'
    updated_at = <Date 2020-03-24.10:30:42.551>
    user = 'https://github.com/petere'

    bugs.python.org fields:

    activity = <Date 2020-03-24.10:30:42.551>
    actor = 'petere'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-02-13.02:00:28.910>
    closer = 'benjamin.peterson'
    components = ['Interpreter Core']
    creation = <Date 2020-02-12.11:55:07.068>
    creator = 'petere'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39615
    keywords = ['patch']
    message_count = 7.0
    messages = ['361880', '361884', '361914', '361915', '361928', '364153', '364923']
    nosy_count = 4.0
    nosy_names = ['eric.smith', 'benjamin.peterson', 'petere', 'serhiy.storchaka']
    pr_nums = ['18481']
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39615'
    versions = ['Python 3.9']

    @petere
    Copy link
    Mannequin Author

    petere mannequin commented Feb 12, 2020

    Some inline functions use mixed declarations and code. These end up visible in third-party code that includes Python.h, which might not be using a C99 compiler.

    Example:

    In file included from /Users/peter/python-builds/3.9/include/python3.9/abstract.h:843,
    from /Users/peter/python-builds/3.9/include/python3.9/Python.h:147,
    from plpython.h:59,
    from plpy_typeio.h:10,
    from plpy_cursorobject.h:8,
    from plpy_cursorobject.c:14:
    /Users/peter/python-builds/3.9/include/python3.9/cpython/abstract.h:74:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
    74 | Py_ssize_t offset = tp->tp_vectorcall_offset;
    | ^~~~~~~~~~

    @petere petere mannequin added 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Feb 12, 2020
    @ericvsmith
    Copy link
    Member

    PEP-7 says that this is allowed:

    Python versions greater than or equal to 3.6 use C89 with several select C99 features:
    ...

    • intermingled declarations

    So I don't think these changes should be accepted.

    @petere
    Copy link
    Mannequin Author

    petere mannequin commented Feb 12, 2020

    That's fair for code internal to CPython itself, but these are header files included by third-party code that is embedding Python, so a bit more flexibility and adaptability would be welcome there.

    @ericvsmith
    Copy link
    Member

    I'd suggest mentioning this on python-dev, if you want to change the policy.

    @benjaminp
    Copy link
    Contributor

    C99 is not disallowed in headers.

    @serhiy-storchaka
    Copy link
    Member

    I think we should distinguish minimal supported C standard for compiling CPython itself and for compiling extensions. We can use all C99 features supported by main compilers in the code of CPython, but C99 is not even compatible with C++, and it may be not compatible with extensions written in other languages (D, Rust, Go, etc), so I think we should use more restricted version in headers.

    @petere
    Copy link
    Mannequin Author

    petere mannequin commented Mar 24, 2020

    3.9.0a5 fixes my original issue. Thanks.

    @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.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants