[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread Eric Snow
Eric Snow added the comment: Your problem is with UserList. This is from the implementation: def __getitem__(self, i): if isinstance(i, slice): return self.__class__(self.data[i]) else: return self.data[i] So each slice is creating a new Tree.

[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread ctarn
ctarn added the comment: OK, I mean... when I call `a = list(b)`, list() changes `b` unexpectedly, not `a != b` in this case. That is why I replace the left operand with `_`. -- ___ Python tracker

[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread ctarn
ctarn added the comment: I printed the value of *.owner before and after `_ = list(d...)`, and marked the results in the comments. -- ___ Python tracker ___

[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread ctarn
ctarn added the comment: Hi, thanks. It did call `list()` through `_ = list(d[0:2])` -- ___ Python tracker ___ ___

[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: Can you give an example? Something simple, showing what you tried, what you expected, and what happened instead. This may help: http://sscce.org/ Your bug.py file doesn't ever use the result of calling list(), so how do you know it changes the value of

[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread ctarn
ctarn added the comment: In the code, each item of ls = [[0], [1], [2],...] has an owner pointing to d, which is a Tree inheriting from collections.UserList. When `d[0] = a`, and `a.owner = d`, and `_ = list(d[0:1])` is called, a.owner will be changed to d[0:1]. --

[issue39110] It seems that list() changes the value of the parameter

2019-12-20 Thread ctarn
Change by ctarn : -- title: It seems that unittest.TestCase.assertListEqual changes the value of its parameters -> It seems that list() changes the value of the parameter Added file: https://bugs.python.org/file48797/bug.py ___ Python tracker