Skip to content

Commit

Permalink
Fix issue when accessing a dict_keys by index
Browse files Browse the repository at this point in the history
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) <[email protected]>
  • Loading branch information
vinzenz and Rezney committed Jul 15, 2021
1 parent 089c3e0 commit fc20c96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion repos/system_upgrade/common/libraries/overlaygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fc20c96

Please sign in to comment.