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

deepcopy can't handle custom metaclasses #36650

Closed
glchapman mannequin opened this issue May 26, 2002 · 3 comments
Closed

deepcopy can't handle custom metaclasses #36650

glchapman mannequin opened this issue May 26, 2002 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@glchapman
Copy link
Mannequin

glchapman mannequin commented May 26, 2002

BPO 560794
Nosy @gvanrossum
Files
  • copy.py.diff
  • copy.py.diff
  • 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/gvanrossum'
    closed_at = <Date 2002-06-10.21:10:39.000>
    created_at = <Date 2002-05-26.19:15:21.000>
    labels = ['library']
    title = "deepcopy can't handle custom metaclasses"
    updated_at = <Date 2002-06-10.21:10:39.000>
    user = 'https://bugs.python.org/glchapman'

    bugs.python.org fields:

    activity = <Date 2002-06-10.21:10:39.000>
    actor = 'gvanrossum'
    assignee = 'gvanrossum'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2002-05-26.19:15:21.000>
    creator = 'glchapman'
    dependencies = []
    files = ['494', '495']
    hgrepos = []
    issue_num = 560794
    keywords = []
    message_count = 3.0
    messages = ['10933', '10934', '10935']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'glchapman']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue560794'
    versions = ['Python 2.2']

    @glchapman
    Copy link
    Mannequin Author

    glchapman mannequin commented May 26, 2002

    This is essentially the same problem as that reported in
    bug 494904 for pickle: deepcopy should treat instances
    of custom metaclasses the same way it treats
    instances of type 'type'. I've attached a provisional fix
    which is basically a copy of the patch made to pickle (it
    checks to see if the type of the thing being deepcopied
    is a subclass of type).

    One question: it seems to me that the exception
    handling code is unnecessary both here and in the
    pickle module. In both cases, the first parameter to
    subclass is the result of a call to 'type' and the second
    is type 'type' itself, so it doesn't seem like there's any
    reason to worry about a TypeError.

    @glchapman glchapman mannequin closed this as completed May 26, 2002
    @glchapman glchapman mannequin assigned gvanrossum May 26, 2002
    @glchapman glchapman mannequin added the stdlib Python modules in the Lib dir label May 26, 2002
    @glchapman glchapman mannequin closed this as completed May 26, 2002
    @glchapman glchapman mannequin assigned gvanrossum May 26, 2002
    @glchapman glchapman mannequin added the stdlib Python modules in the Lib dir label May 26, 2002
    @glchapman
    Copy link
    Mannequin Author

    glchapman mannequin commented May 26, 2002

    Logged In: YES
    user_id=86307

    I changed the patch so that issubclass is called before the
    attempt to access __deepcopy__ (to avoid unbound instance
    method problem methioned in 494904).

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Thanks; I've checked this in. For the reason of the except
    clause, see python.org/sf/502085.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant