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

Frozen dataclass __init__ fails for "object" property" #78394

Closed
Omenien mannequin opened this issue Jul 24, 2018 · 4 comments
Closed

Frozen dataclass __init__ fails for "object" property" #78394

Omenien mannequin opened this issue Jul 24, 2018 · 4 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Omenien
Copy link
Mannequin

Omenien mannequin commented Jul 24, 2018

BPO 34213
Nosy @ericvsmith, @miss-islington, @VadimPushtaev
PRs
  • bpo-34213: frozen dataclass with "object" attr bug #8452
  • [3.7] bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452) #8745
  • [3.7] bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452) #8746
  • Files
  • frozen_dataclass_init_typeerror.py: Minimal .py demonstrating the error
  • 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 2018-09-10.22:43:33.896>
    created_at = <Date 2018-07-24.18:34:20.201>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'Frozen dataclass __init__ fails for "object" property"'
    updated_at = <Date 2018-09-10.22:43:33.895>
    user = 'https://bugs.python.org/Omenien'

    bugs.python.org fields:

    activity = <Date 2018-09-10.22:43:33.895>
    actor = 'eric.smith'
    assignee = 'eric.smith'
    closed = True
    closed_date = <Date 2018-09-10.22:43:33.896>
    closer = 'eric.smith'
    components = ['Library (Lib)']
    creation = <Date 2018-07-24.18:34:20.201>
    creator = 'Omenien'
    dependencies = []
    files = ['47710']
    hgrepos = []
    issue_num = 34213
    keywords = ['patch']
    message_count = 4.0
    messages = ['322321', '322332', '323441', '323459']
    nosy_count = 4.0
    nosy_names = ['eric.smith', 'miss-islington', 'Omenien', 'Vadim Pushtaev']
    pr_nums = ['8452', '8745', '8746']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34213'
    versions = ['Python 3.7', 'Python 3.8']

    @Omenien
    Copy link
    Mannequin Author

    Omenien mannequin commented Jul 24, 2018

    When __init__ is called for a class which 1) is annotated with @dataclasses.dataclass(frozen=True) and 2) has a attribute named object a TypeError is raised because object is overridden for the local scope and as a result __setattr__ is called on the passed in argument value instead of the standard object base type.

    I was able to reproduce this in a Docker container running https://github.com/docker-library/python/blob/7a794688c7246e7eff898f5288716a3e7dc08484/3.7/stretch/Dockerfile with the attached .py file.
    Python 3.7.0 (default, Jul 17 2018, 11:04:33)
    [GCC 6.3.0 20170516] on linux

    @Omenien Omenien mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jul 24, 2018
    @ericvsmith ericvsmith self-assigned this Jul 24, 2018
    @VadimPushtaev
    Copy link
    Mannequin

    VadimPushtaev mannequin commented Jul 24, 2018

    Hello.

    This is my solution for this problem - #8452

    Sorry if I'm not supposed to do anything about the already assigned issue, feel free to ignore my PR.

    @ericvsmith
    Copy link
    Member

    New changeset 4d12e4d by Eric V. Smith (Vadim Pushtaev) in branch 'master':
    bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)
    4d12e4d

    @miss-islington
    Copy link
    Contributor

    New changeset 32e58fc by Miss Islington (bot) in branch '3.7':
    bpo-34213: Allow dataclasses to work with a field named 'object'. (GH-8452)
    32e58fc

    @ericvsmith ericvsmith added the 3.8 only security fixes label Sep 10, 2018
    @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 3.8 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

    2 participants