From cb370593df2d30c33afb804042f25944f5bca08d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 1 Aug 2019 16:01:22 +0200 Subject: [PATCH] Small fix to correctly handle default arguments Dictionaries are mutable, and should not be assigned as a default parameter. Change-Id: Id08c17f89c17b404560241849603e1e1a0ec6562 Reviewed-by: Simon Hausmann --- util/cmake/pro2cmake.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py index a62b094ee97..843b2e7bacd 100755 --- a/util/cmake/pro2cmake.py +++ b/util/cmake/pro2cmake.py @@ -374,10 +374,14 @@ class Scope(object): parent_scope: typing.Optional[Scope], file: typing.Optional[str] = None, condition: str = '', base_dir: str = '', - operations: typing.Mapping[str, typing.List[Operation]] = { - 'QT_SOURCE_TREE': [SetOperation(['${QT_SOURCE_TREE}'])], - 'QT_BUILD_TREE': [SetOperation(['${PROJECT_BUILD_DIR}'])], - }) -> None: + operations: typing.Union[ + typing.Mapping[str, typing.List[Operation]], None] = None) -> None: + if operations is None: + operations = { + 'QT_SOURCE_TREE': [SetOperation(['${QT_SOURCE_TREE}'])], + 'QT_BUILD_TREE': [SetOperation(['${PROJECT_BUILD_DIR}'])], + } + self._operations = copy.deepcopy(operations) if parent_scope: parent_scope._add_child(self)