|
From: | John Snow |
Subject: | Re: [Qemu-devel] [PATCH v2 02/10] qemu|qtest: Avoid dangerous arguments |
Date: | Tue, 25 Jul 2017 13:14:25 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 07/25/2017 11:09 AM, Lukáš Doktor wrote:
The list object is mutable in python and potentially might modify other object's arguments when used as default argument. Reproducer: >>> vm1 = QEMUMachine("qemu") >>> vm2 = QEMUMachine("qemu") >>> vm1._wrapper.append("foo") >>> print vm2._wrapper ['foo'] In this case the `args` is actually copied so it would be safe to keep it, but it's not a good practice to keep it. The same issue applies in inherited qtest module.
ohh, grr, this trips me up in Python all the time. Definitely best to remove such usages where possible.
Signed-off-by: Lukáš Doktor <address@hidden> Reviewed-by: Eduardo Habkost <address@hidden>
Reviewed-by: John Snow <address@hidden>
[Prev in Thread] | Current Thread | [Next in Thread] |