[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/11] qemu.py: Avoid dangerous arguments
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH 02/11] qemu.py: Avoid dangerous arguments |
Date: |
Thu, 20 Jul 2017 15:19:24 -0300 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Thu, Jul 20, 2017 at 06:28:06PM +0200, 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.
>
> Signed-off-by: Lukáš Doktor <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
--
Eduardo
- [Qemu-devel] [PATCH 00/11] qemu.py: Pylint/style fixes, Lukáš Doktor, 2017/07/20
- [Qemu-devel] [PATCH 04/11] qemu.py: Simplify QMP key-conversion, Lukáš Doktor, 2017/07/20
- [Qemu-devel] [PATCH 11/11] qtest.py: Avoid using mutable list as default argument, Lukáš Doktor, 2017/07/20
- [Qemu-devel] [PATCH 03/11] qemu.py: Use iteritems rather than keys(), Lukáš Doktor, 2017/07/20
- [Qemu-devel] [PATCH 02/11] qemu.py: Avoid dangerous arguments, Lukáš Doktor, 2017/07/20
- [Qemu-devel] [PATCH 08/11] qmp.py: Avoid "has_key" usage, Lukáš Doktor, 2017/07/20
- [Qemu-devel] [PATCH 05/11] qemu.py: Use custom exceptions rather than Exception, Lukáš Doktor, 2017/07/20