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

Make _Py_PackageContext of type "const char *" #72934

Closed
serhiy-storchaka opened this issue Nov 20, 2016 · 6 comments
Closed

Make _Py_PackageContext of type "const char *" #72934

serhiy-storchaka opened this issue Nov 20, 2016 · 6 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 28748
Nosy @brettcannon, @ncoghlan, @ericsnowcurrently, @serhiy-storchaka
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • _Py_PackageContext-const.patch
  • _Py_PackageContext-const-2.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-21.08:27:08.292>
    created_at = <Date 2016-11-20.09:32:00.472>
    labels = ['interpreter-core', 'type-feature', '3.7']
    title = 'Make _Py_PackageContext of type "const char *"'
    updated_at = <Date 2017-03-31.16:36:10.152>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:10.152>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-11-21.08:27:08.292>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-11-20.09:32:00.472>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['45556', '45567']
    hgrepos = []
    issue_num = 28748
    keywords = ['patch']
    message_count = 6.0
    messages = ['281256', '281266', '281298', '281331', '281333', '281334']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'python-dev', 'eric.snow', 'serhiy.storchaka']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue28748'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    Currently _Py_PackageContext has type "char *". But it is either NULL or a pointer to internal readonly UTF-8 representation of Unicode object. Adding the const qualifier makes it clear that the data is immutable. I don't think this change will break third-party code.

    @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 20, 2016
    @ncoghlan
    Copy link
    Contributor

    It technically could (if they're passing it to a function that takes a "char *"), but if they are and they can't change the affected function to take "const char *" instead, then that's an actual bug in the way they're using it.

    So +1 from me for explicitly declaring the immutability in 3.7+ - it will need a note in the What's New porting guide though.

    @serhiy-storchaka
    Copy link
    Member Author

    Added a What's New note.

    On GitHub I found only three projects (besides clones of CPython sources) that use _Py_PackageContext. They are not affected by this change.

    @ncoghlan
    Copy link
    Contributor

    Ah, my apologies - for some reason I completely failed to notice the leading underscore until I saw you refer to this as a private variable in the What's New note.

    That means the note only needs to go in the NEWS file for the benefit of maintainers, rather than in the public porting notes. Sorry for overcomplicating things :)

    Aside from my confusion about this actually being a private interface, the patch looks good to me.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 21, 2016

    New changeset d2dd6578aa16 by Serhiy Storchaka in branch 'default':
    Issue bpo-28748: Private variable _Py_PackageContext is now of type "const char *"
    https://hg.python.org/cpython/rev/d2dd6578aa16

    @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