[PATCH 5/9] Make map() usage Python 3 compatible (#1014220)
Martin Kolman
mkolman at redhat.com
Wed Jan 28 17:43:19 UTC 2015
In Python 3 map() no longer returns a list, but an iterator.
So replace map() with list comprehension or wrap it with list()
where a list is expected. No changes are needed in code that either
works fine with an iterator or just uses map() for the side effects.
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
pyanaconda/keyboard.py | 6 ++++--
pyanaconda/rescue.py | 2 +-
pyanaconda/ui/gui/spokes/filter.py | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
index 1f3e572..e937f6e 100644
--- a/pyanaconda/keyboard.py
+++ b/pyanaconda/keyboard.py
@@ -399,8 +399,10 @@ class LocaledWrapper(object):
# if there are more variants than layouts, throw the trailing ones away
variants = variants[:len(layouts)]
- # map can be used with multiple lists and works like zipWith (Haskell)
- return map(join_layout_variant, layouts, variants)
+ # map can be used with multiple lists and works like zipWith (Haskell),
+ # but we need to wrap it in list so that callers of this method still
+ # get a list in Python 3
+ return list(map(join_layout_variant, layouts, variants))
@property
def options(self):
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index 6702e2b..d52a8ff 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -382,7 +382,7 @@ def doRescue(intf, rescue_mount, ksdata):
# set a library path to use mounted fs
libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":")
- mounted = map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)
+ mounted = ["/mnt/sysimage%s" % mdir for mdir in libdirs]
os.environ["LD_LIBRARY_PATH"] = ":".join(libdirs + mounted)
# find groff data dir
diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py
index 1e2a3ac..3003b0f 100644
--- a/pyanaconda/ui/gui/spokes/filter.py
+++ b/pyanaconda/ui/gui/spokes/filter.py
@@ -508,8 +508,8 @@ class FilterSpoke(NormalSpoke):
self.disks = getDisks(self.storage.devicetree)
self.selected_disks = self.data.ignoredisk.onlyuse[:]
- self.ancestors = itertools.chain(*map(self._real_ancestors, self.disks))
- self.ancestors = map(lambda d: d.name, self.ancestors)
+ self.ancestors = itertools.chain(*list(map(self._real_ancestors, self.disks)))
+ self.ancestors = [d.name for d in self.ancestors]
self._store.clear()
--
2.1.0
More information about the anaconda-patches
mailing list