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 for char and wchar_t pointers to unmodifiable strings #76422

Closed
serhiy-storchaka opened this issue Dec 7, 2017 · 2 comments
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 32241
Nosy @vstinner, @serhiy-storchaka
PRs
  • bpo-32241: Add the const qualifire to declarations of umodifiable strings. #4748
  • 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 2017-12-12.11:55:32.591>
    created_at = <Date 2017-12-07.13:54:04.793>
    labels = ['interpreter-core', 'type-feature', '3.7']
    title = 'Add the const qualifier for char and wchar_t pointers to unmodifiable strings'
    updated_at = <Date 2017-12-12.11:55:32.590>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-12-12.11:55:32.590>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-12-12.11:55:32.591>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-12-07.13:54:04.793>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32241
    keywords = ['patch']
    message_count = 2.0
    messages = ['307802', '308119']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'serhiy.storchaka']
    pr_nums = ['4748']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32241'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    Py_SetProgramName() and Py_SetPythonHome() take a pointer to a string that shouldn't be changed for the duration of the program's execution. But the type of their arguments is "wchar_t *", therefore passing just a pointer to a constant static string will cause a compiler warning. The proposed PR changes the type to "const wchar_t *". This is backward compatible change.

    The PR also adds the const qualifier to internal pointers that point on to unmodifiable strings. This could help to distinguish them from pointers on modifiable strings and can prevent unintentional modifications.

    @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 Dec 7, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 4ae06c5 by Serhiy Storchaka in branch 'master':
    bpo-32241: Add the const qualifire to declarations of umodifiable strings. (bpo-4748)
    4ae06c5

    @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

    1 participant