From patchwork Tue May 23 15:09:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1785286 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=CLT0A+G+; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QQd5Q41vlz2020 for ; Wed, 24 May 2023 01:09:29 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q1TdT-0002UF-RH; Tue, 23 May 2023 15:09:15 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q1TdS-0002U2-06 for kernel-team@lists.ubuntu.com; Tue, 23 May 2023 15:09:14 +0000 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 35FA43F4A6 for ; Tue, 23 May 2023 15:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684854549; bh=aTMAYkvdlz7jNihQsh0cVYkxyMmhkWCmNHjHLaM3XjM=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=CLT0A+G+zCBYwx0NorH5wyLsreZyV/j4G/2XdNSqHMfGdcyQXReJakaHCOlVWN1Gk 8cJm5xvs+OXFMMvX+6Y7yeZQ0VjCMe9pH16Q/zhMFFCdHGnCIJgxuQCicZqUgDDGxR PzTIknBHpssD5rMR1/zSpJ4dTjIl1JQSOJ/7wPDBpd+eWJvSYlfdwZdE1kgtDXNbn4 6U/UmlfQQ6xkFJseBYvXKk2849btTr6yPb3TGYZZ2NkIeMIC8FZp5ILqMlIeX4zpV4 Z3ovY2vK/5lJXYefFb7QUHDwVDWziX3vRhMQnFV+nMBKEYMJqkcwtwdrbwr9T7Q6P6 sJMCAGtxCm05A== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96f4f1bb838so563553966b.3 for ; Tue, 23 May 2023 08:09:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684854549; x=1687446549; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aTMAYkvdlz7jNihQsh0cVYkxyMmhkWCmNHjHLaM3XjM=; b=FAsjcllqWzJmLIRDSwy0oo4+Ftp1AItBDZ0Gs4RXA/pAWkx9IicDyH7FzuYEzlJq4b YP5u0TZ3a346xvforh7P4D+xtpK3iE4OdDwjbE1ERy55Oo3qouYgvjaoPp53GCKn8CQ1 NmKxQ9MvrBsFNxMiS6RODkJeCv5z13kqB9SDXBj92ZV73G+nYW3uqov9YNkuFbIyVNe9 SSrh4fqhAZ0NhCDA9qS8UtanB7/cBF53NwkLSluAWXtpyz0B2atmQHHl+cfevQoMi6NV rCBSWpasGR0FGqmoeu1AwxrpSyyIn7PkdGbO6HFOqZu6mLw1cQG7t9wIuJ4hN8o0JCQY O2/A== X-Gm-Message-State: AC+VfDyxs0A92TUbQYRQULukFbpTCf2tSctatD+GKf7kPLd+bMqqwJeU ziaMEonheT1uUfqN+yQzwcXU9Dd1ughyihsABuMpEltQBoSaV17to3dOZGk21jEkUgdXJgUWTXo PV5tmjky+PKS8Do3hq70yrkeo+33e0j7koqWUPeFO/XpICG1O/A== X-Received: by 2002:a17:906:d54a:b0:94e:f738:514f with SMTP id cr10-20020a170906d54a00b0094ef738514fmr13046919ejc.13.1684854548833; Tue, 23 May 2023 08:09:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5n7oZPygwe+bpGPBmTe51YjfX6vMHWfpOKhqLacUHFtmo3NymC2yuFKpn5Oj8Yl+PSGJIetw== X-Received: by 2002:a17:906:d54a:b0:94e:f738:514f with SMTP id cr10-20020a170906d54a00b0094ef738514fmr13046877ejc.13.1684854548227; Tue, 23 May 2023 08:09:08 -0700 (PDT) Received: from righiandr-XPS-13-7390.homenet.telecomitalia.it (host-82-49-64-69.retail.telecomitalia.it. [82.49.64.69]) by smtp.gmail.com with ESMTPSA id jy22-20020a170907763600b0096fbc516a93sm3588042ejc.211.2023.05.23.08.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 08:09:07 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][M][L][J][PATCH] UBUNTU: [Packaging] kconfig/annotations.py: support older way of merging dicts Date: Tue, 23 May 2023 17:09:06 +0200 Message-Id: <20230523150906.409543-1-andrea.righi@canonical.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2020531 The '|=' update operator for merging dicts is available starting in python 3.9 however in focal we have python 3.8, which causes the annotation parsing script to crash. Support also the old way of merging dicts available since python 3.5 that uses dict unpacking, e.g. dict1 = {**dict1, **dict2} Signed-off-by: Luke Nowakowski-Krijger Signed-off-by: Andrea Righi Acked-by: Tim Gardner Acked-by: Luke Nowakowski-Krijger --- debian/scripts/misc/kconfig/annotations.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index dcc133dbbf62..b521bd0c7135 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -105,7 +105,10 @@ class Annotation(Config): m = re.match(r'.* policy<(.*?)>', line) if m: match = True - entry['policy'] |= literal_eval(m.group(1)) + try: + entry['policy'] |= literal_eval(m.group(1)) + except TypeError: + entry['policy'] = {**entry['policy'], **literal_eval(m.group(1))} m = re.match(r'.* note<(.*?)>', line) if m: @@ -204,7 +207,10 @@ class Annotation(Config): # Determine if we need to import all configs or a single config if not configs: configs = c.config.keys() - configs |= self.search_config(arch=arch, flavour=flavour).keys() + try: + configs |= self.search_config(arch=arch, flavour=flavour).keys() + except TypeError: + configs = {**configs, **self.search_config(arch=arch, flavour=flavour).keys()} # Import configs from the Kconfig object into Annotations if flavour is not None: @@ -335,8 +341,12 @@ class Annotation(Config): # If new_val is a subset of old_val, skip it old_val = tmp_a.config.get(conf) if old_val and 'policy' in old_val: - if old_val['policy'] == old_val['policy'] | new_val['policy']: - continue + try: + if old_val['policy'] == old_val['policy'] | new_val['policy']: + continue + except TypeError: + if old_val['policy'] == {**old_val['policy'], **new_val['policy']}: + continue # Write out the policy (and note) line(s) val = dict(sorted(new_val['policy'].items()))