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

Add the const qualifier to fields name and doc of public structs #72947

Closed
serhiy-storchaka opened this issue Nov 21, 2016 · 4 comments
Closed
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 28761
Nosy @ncoghlan, @serhiy-storchaka
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • const-name-and-doc-fields.patch
  • 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 2016-11-22.06:04:38.269>
    created_at = <Date 2016-11-21.09:40:15.884>
    labels = ['interpreter-core', 'type-feature', '3.7']
    title = 'Add the const qualifier to fields name and doc of public structs'
    updated_at = <Date 2017-03-31.16:36:34.032>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:34.032>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-11-22.06:04:38.269>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-11-21.09:40:15.884>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['45581']
    hgrepos = []
    issue_num = 28761
    keywords = ['patch']
    message_count = 4.0
    messages = ['281340', '281357', '281434', '281436']
    nosy_count = 3.0
    nosy_names = ['ncoghlan', 'python-dev', 'serhiy.storchaka']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue28761'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    Proposed patch makes the fields name and doc of structures PyMemberDef, PyGetSetDef, PyStructSequence_Field, PyStructSequence_Desc, and wrapperbase being of type "const char *" rather of "char *".

    These structures often are initialized as static variables and name and doc fields are initialized from literal strings. These fields are always refer to constant string literal, NULL, or readonly UTF8 representation of a Unicode object. They are never refer to mutable data. Changing the data referred by these pointers is an error. Adding the const qualifier makes clear that this is an immutable data.

    This change may need some changes in third-party code. But it needs to change only one line in CPython sources, and I believe that most third-party projects don't need any changes at all.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Nov 21, 2016
    @ncoghlan
    Copy link
    Contributor

    +1 from me. The only thing I noticed in the patch was that the issue number needs filling in now that you've filed it.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 22, 2016

    New changeset 42b0ba372ec2 by Serhiy Storchaka in branch 'default':
    Issue bpo-28761: The fields name and doc of structures PyMemberDef, PyGetSetDef,
    https://hg.python.org/cpython/rev/42b0ba372ec2

    @serhiy-storchaka
    Copy link
    Member Author

    Thanks Nick.

    @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.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants