Skip to content

Add the const qualifier for char and wchar_t pointers to unmodifiable strings #76422

Closed

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on Dec 7, 2017

      @serhiy-storchaka
      MemberAuthor

      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.

    2. added
      3.7 (EOL)
      interpreter-core
      type-feature
      on Dec 7, 2017
    3. serhiy-storchaka commented on Dec 12, 2017

      @serhiy-storchaka
      MemberAuthor

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

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

      3.7 (EOL)interpreter-coretype-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions