Issue 14756: Empty Dict in Initializer is Shared Betwean Objects (original) (raw)

When initializing a class with an empty dict() object as a default initializer, if it is not overridden, multiple instances of the class will share the dictionary. IE:

class test(object): def init(self, obj=dict()): self.obj = obj

a = test() b = test()

Then id(a.obj) points to the same location as id(b.obj). The behaviour I would expect would be that a.obj and b.obj would be unique instances.