mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[gyb] Convert map object to list object
Python 2's map function [1] returns a list by default. Compared with Python 3's map function [2] which returns an iterator (or map object). The former is subscriptable, while the latter is not. This patch explicitly converts the result of some map operations to be a list. That way they have the same intended behaviour on both Python 2 and 3. [1] https://docs.python.org/2/library/functions.html#map [2] https://docs.python.org/3/library/functions.html#map
This commit is contained in:
@@ -331,7 +331,10 @@ class UnicodeTrieGenerator(object):
|
||||
else:
|
||||
return idx
|
||||
|
||||
return map(map_index, indexes)
|
||||
# NOTE: Python 2's `map` function returns a list. Where Python 3's
|
||||
# `map` function returns an iterator. To work around this the
|
||||
# result of the `map` is explicitly converted to a `list`.
|
||||
return list(map(map_index, indexes))
|
||||
|
||||
# If self.BMP_data contains identical data blocks, keep the first one,
|
||||
# remove duplicates and change the indexes in self.BMP_lookup to point to
|
||||
|
||||
Reference in New Issue
Block a user