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 PyExceptionClass_Name returning a const string #77999

Closed
serhiy-storchaka opened this issue Jun 10, 2018 · 3 comments
Closed

Make PyExceptionClass_Name returning a const string #77999

serhiy-storchaka opened this issue Jun 10, 2018 · 3 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 33818
Nosy @ned-deily, @serhiy-storchaka
PRs
  • bpo-33818: PyExceptionClass_Name() will now return "const char *". #7581
  • 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 2018-06-15.08:10:50.717>
    created_at = <Date 2018-06-10.06:35:52.549>
    labels = ['interpreter-core', 'type-feature', '3.8']
    title = 'Make PyExceptionClass_Name returning a const string'
    updated_at = <Date 2018-06-15.08:10:50.716>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-06-15.08:10:50.716>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-06-15.08:10:50.717>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2018-06-10.06:35:52.549>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33818
    keywords = ['patch']
    message_count = 3.0
    messages = ['319201', '319255', '319593']
    nosy_count = 2.0
    nosy_names = ['ned.deily', 'serhiy.storchaka']
    pr_nums = ['7581']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33818'
    versions = ['Python 3.8']

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Jun 10, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    PyExceptionClass_Name() returns just the tp_name field, a pointer to immutable char array. tp_name had type "char *" in old Python versions, but it was changed to "const char *" in revision af68c87.

    But PyExceptionClass_Name() still casts tp_name to "char *". I think it would be better to return "const char *". It would be a breaking change, but seems most third-party code uses the result of PyExceptionClass_Name() in context where "const char *" is acceptable [1], and it is easy to add "const" in a variable declaration if the result is assigned to a variable (as in both cases of using PyExceptionClass_Name() in the CPython core).

    Since several similar breaking changes were made in 3.7 (see bpo-28761 and bpo-28769), it would be nice to made this change in 3.7 too. But it may be too late for 3.7.

    [1] https://github.com/search?q=PyExceptionClass_Name&type=Code

    @ned-deily
    Copy link
    Member

    While I think the change makes sense aesthetically, I do not see a compelling reason why such a user interface change should be introduced to 3.7 at literally the last moment. Let's do it for 3.8, please.

    @ned-deily ned-deily removed the 3.7 (EOL) end of life label Jun 10, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset ceeef10 by Serhiy Storchaka in branch 'master':
    bpo-33818: PyExceptionClass_Name() will now return "const char *". (GH-7581)
    ceeef10

    @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.8 only security fixes 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