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

strange list.sort() behavior on import, del and inport again #50142

Closed
dstemmer mannequin opened this issue May 1, 2009 · 2 comments
Closed

strange list.sort() behavior on import, del and inport again #50142

dstemmer mannequin opened this issue May 1, 2009 · 2 comments

Comments

@dstemmer
Copy link
Mannequin

dstemmer mannequin commented May 1, 2009

BPO 5892
Nosy @loewis
Files
  • bugs.rar
  • 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 2009-05-01.06:31:53.187>
    created_at = <Date 2009-05-01.04:51:57.351>
    labels = ['invalid']
    title = 'strange list.sort() behavior on import, del and inport again'
    updated_at = <Date 2009-05-01.06:31:53.158>
    user = 'https://bugs.python.org/dstemmer'

    bugs.python.org fields:

    activity = <Date 2009-05-01.06:31:53.158>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-05-01.06:31:53.187>
    closer = 'loewis'
    components = []
    creation = <Date 2009-05-01.04:51:57.351>
    creator = 'dstemmer'
    dependencies = []
    files = ['13826']
    hgrepos = []
    issue_num = 5892
    keywords = []
    message_count = 2.0
    messages = ['86862', '86865']
    nosy_count = 2.0
    nosy_names = ['loewis', 'dstemmer']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue5892'
    versions = ['Python 2.6']

    @dstemmer
    Copy link
    Mannequin Author

    dstemmer mannequin commented May 1, 2009

    Given two modules, I've seen the following kind of strange behavior with
    list sorting on import and delete; a list that has been imported, sorted
    and deleted remains sorted on a second import:

    my_module.py:

    some_list = ['b','a']

    other_module.py:

    from  my_module import some_list
    print some_list
    some_list.sort()
    print some_list
    del some_list
    from  my_module import some_list
    print some_list

    Output is:

    ['b','a']
    ['a','b']
    ['a','b']

    Sorry if it's already been reported.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 1, 2009

    That is not a bug in Python. The import statement merely adds a
    reference to the list into your module, so both variables point to the
    very same list (my_module.some_list is other_module.some_list).
    Therefore, any changes made to the list through my_module will also
    affect the list as seen from other_module.

    Closing the report as invalid.

    @loewis loewis mannequin closed this as completed May 1, 2009
    @loewis loewis mannequin added the invalid label May 1, 2009
    @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
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants