-
-
Couldn't load subscription status.
- Fork 33.3k
Description
Bug report
Bug description:
I am not completely sure why this is happening, but here is the minimal reproducible example:
class TestClass:
someVar: list[str] = []
def __init__(self, string: str) -> None:
self.someVar.append(string)
def __repr__(self):
return self.someVar.__repr__()
l: list[TestClass] = []
for i in range(10):
t = TestClass(str(i))
l.append(t)
print(l)Expected output:
[['0'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9']]
Actual output:
[['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']]
My way of fixing has currently been something along the lines of this:
...
def __init__(self) -> None:
self.someVar = []
...I have not yet tested this with different types. Also, if I am doing something wrong, please tell me.
CPython versions tested on:
3.14
Operating systems tested on:
Windows