mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
WmiClass: Don't share "versions" between instances
Lists in Python are mutable and when used as a default value of a parameter for class constructor, its value will be shared between all class instances. Example: class Test: def __init__(self, mylist=[]): self.mylist = mylist A = Test() B = Test() A.mylist.append("mylist from instance A") print(B.mylist) # Will print ['mylist from instance A'] Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
This commit is contained in:
parent
5e870cbda4
commit
94f417baa9
@ -44,9 +44,9 @@ class WmiClass:
|
||||
to.
|
||||
"""
|
||||
|
||||
def __init__(self, name, versions = []):
|
||||
def __init__(self, name, versions=None):
|
||||
self.name = name
|
||||
self.versions = versions
|
||||
self.versions = versions if versions else list()
|
||||
self.common = None
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user