From fc20c960ebcc49add45283933b38b23c77288182 Mon Sep 17 00:00:00 2001 From: Vinzenz Feenstra Date: Thu, 8 Jul 2021 10:24:41 +0000 Subject: [PATCH] Fix issue when accessing a dict_keys by index In Python 3 the dict.keys() method no longer returns an indexable list but an iterator. This patch fixes the problem by converting the value returned to a list before accessing the element by index. Co-Authored-By: Michal Reznik (mreznik) --- .../actors/peseventsscanner/libraries/peseventsscanner.py | 2 +- repos/system_upgrade/common/libraries/overlaygen.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/repos/system_upgrade/common/actors/peseventsscanner/libraries/peseventsscanner.py b/repos/system_upgrade/common/actors/peseventsscanner/libraries/peseventsscanner.py index 7a121c2def..5bdd2622cb 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/libraries/peseventsscanner.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/libraries/peseventsscanner.py @@ -619,7 +619,7 @@ def produce_messages(tasks): # Type casting to list to be Py2&Py3 compatible as on Py3 keys() returns dict_keys(), not a list to_install_pkgs = sorted(tasks[Task.INSTALL].keys()) to_remove_pkgs = sorted(tasks[Task.REMOVE].keys()) - to_enable_repos = sorted(set(tasks[Task.INSTALL].values() + tasks[Task.KEEP].values())) + to_enable_repos = sorted(set(list(tasks[Task.INSTALL].values()) + list(tasks[Task.KEEP].values()))) if to_install_pkgs or to_remove_pkgs: api.produce(PESRpmTransactionTasks(to_install=to_install_pkgs, diff --git a/repos/system_upgrade/common/libraries/overlaygen.py b/repos/system_upgrade/common/libraries/overlaygen.py index 8abb65117a..0e46e43923 100644 --- a/repos/system_upgrade/common/libraries/overlaygen.py +++ b/repos/system_upgrade/common/libraries/overlaygen.py @@ -77,7 +77,7 @@ def _build_overlay_mount(root_mount, mounts): if not mounts: yield root_mount else: - current = mounts.keys()[0] + current = list(mounts.keys())[0] current_mount = mounts.pop(current) name = _mount_name(current) with current_mount: