Skip to content

Magic class member variable initialization with lists #45784

Closed

Description

@neoone
mannequin
BPO 1443
Nosy @gvanrossum
Files
  • test.py
  • 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 2007-11-14.19:19:50.559>
    created_at = <Date 2007-11-14.19:10:35.370>
    labels = ['interpreter-core', 'type-bug', 'invalid']
    title = 'Magic class member variable initialization with lists'
    updated_at = <Date 2007-11-14.19:19:50.530>
    user = 'https://bugs.python.org/neoone'

    bugs.python.org fields:

    activity = <Date 2007-11-14.19:19:50.530>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2007-11-14.19:19:50.559>
    closer = 'gvanrossum'
    components = ['Interpreter Core']
    creation = <Date 2007-11-14.19:10:35.370>
    creator = 'neoone'
    dependencies = []
    files = ['8745']
    hgrepos = []
    issue_num = 1443
    keywords = []
    message_count = 2.0
    messages = ['57500', '57502']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'neoone']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1443'
    versions = ['Python 2.5']

    Activity

    1. neoone commented on Nov 14, 2007

      neoonemannequin
      MannequinAuthor

      Initialization of member variables with lists leads to strange
      behavior.

      The list object is common to each instance of that class.

      File attached results in:
      [] [] <main.Proof instance at 0x00BA7120>
      ['STICKYARRAY'] [] <main.Proof instance at 0x00BA7148>

      So the initialized list a is the same in both instances.
      Behaviour has been tested on 2.3 and 2.5

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on Nov 14, 2007
    3. gvanrossum commented on Nov 14, 2007

      @gvanrossum
      Member

      Go ask on c.l.py why this is not a bug.

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions