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

Remove namespace copy from dataclasses.make_dataclass() #87986

Closed
ericvsmith opened this issue Apr 12, 2021 · 1 comment
Closed

Remove namespace copy from dataclasses.make_dataclass() #87986

ericvsmith opened this issue Apr 12, 2021 · 1 comment
Assignees
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ericvsmith
Copy link
Member

BPO 43820
Nosy @ericvsmith
PRs
  • bpo-43820: Remove an unnecessary copy of the 'namespace' parameter to make_dataclass() #25372
  • 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 = 'https://github.com/ericvsmith'
    closed_at = <Date 2021-04-14.23:31:18.151>
    created_at = <Date 2021-04-12.21:12:10.351>
    labels = ['type-bug', 'library', '3.10']
    title = 'Remove namespace copy from dataclasses.make_dataclass()'
    updated_at = <Date 2021-04-14.23:31:18.151>
    user = 'https://github.com/ericvsmith'

    bugs.python.org fields:

    activity = <Date 2021-04-14.23:31:18.151>
    actor = 'eric.smith'
    assignee = 'eric.smith'
    closed = True
    closed_date = <Date 2021-04-14.23:31:18.151>
    closer = 'eric.smith'
    components = ['Library (Lib)']
    creation = <Date 2021-04-12.21:12:10.351>
    creator = 'eric.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43820
    keywords = ['patch']
    message_count = 1.0
    messages = ['390907']
    nosy_count = 1.0
    nosy_names = ['eric.smith']
    pr_nums = ['25372']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43820'
    versions = ['Python 3.10']

    @ericvsmith
    Copy link
    Member Author

    In make_dataclasses(), the "namespace" argument is copied because it is mutated. This isn't really necessary: the callback passed to types.new_class() could just update its "ns" parameter with "namespace" and with the new attributes (anotations and default field values).

    This would eliminate the need to copy "namespace".

    @ericvsmith ericvsmith added the 3.10 only security fixes label Apr 12, 2021
    @ericvsmith ericvsmith self-assigned this Apr 12, 2021
    @ericvsmith ericvsmith added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error 3.10 only security fixes labels Apr 12, 2021
    @ericvsmith ericvsmith self-assigned this Apr 12, 2021
    @ericvsmith ericvsmith added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 12, 2021
    @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.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant