Skip to content

Commit 61cb087

Browse files
committed
Remove incorrect usages of map() in distutils.
Reported by Lisandro Dalcin.
1 parent 9a2310d commit 61cb087

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

Lib/distutils/cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def dump_options(self, header=None, indent=""):
158158
print(indent + header)
159159
indent = indent + " "
160160
for (option, _, _) in self.user_options:
161-
option = option.translate(longopt_xlate)
161+
option = longopt_xlate(option)
162162
if option[-1] == "=":
163163
option = option[:-1]
164164
value = getattr(self, option)

Lib/distutils/command/build_ext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def finalize_options(self):
244244

245245
if self.define:
246246
defines = self.define.split(',')
247-
self.define = map(lambda symbol: (symbol, '1'), defines)
247+
self.define = [(symbol, '1') for symbol in defines]
248248

249249
# The option for macros to undefine is also a string from the
250250
# option parsing, but has to be a list. Multiple symbols can also

Lib/distutils/dist.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,8 @@ def _set_command_options (self, command_obj, option_dict=None):
864864
for (option, (source, value)) in option_dict.items():
865865
if DEBUG: print(" %s = %s (from %s)" % (option, value, source))
866866
try:
867-
bool_opts = map(translate_longopt, command_obj.boolean_options)
867+
bool_opts = [translate_longopt(o)
868+
for o in command_obj.boolean_options]
868869
except AttributeError:
869870
bool_opts = []
870871
try:

Lib/distutils/filelist.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ def _parse_template_line(self, line):
8585
if len(words) < 2:
8686
raise DistutilsTemplateError(
8787
"'%s' expects <pattern1> <pattern2> ..." % action)
88-
patterns = map(convert_path, words[1:])
88+
patterns = [convert_path(w) for w in words[1:]]
8989
elif action in ('recursive-include', 'recursive-exclude'):
9090
if len(words) < 3:
9191
raise DistutilsTemplateError(
9292
"'%s' expects <dir> <pattern1> <pattern2> ..." % action)
9393
dir = convert_path(words[1])
94-
patterns = map(convert_path, words[2:])
94+
patterns = [convert_path(w) for w in words[2:]]
9595
elif action in ('graft', 'prune'):
9696
if len(words) != 2:
9797
raise DistutilsTemplateError(

Lib/distutils/mwerkscompiler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ def link (self,
104104
# This is because we (usually) create the project in a subdirectory of
105105
# where we are now, and keeping the paths relative is too much work right
106106
# now.
107-
sources = map(self._filename_to_abs, self.__sources)
108-
include_dirs = map(self._filename_to_abs, self.__include_dirs)
107+
sources = [self._filename_to_abs(s) for s in self.__sources]
108+
include_dirs = [self._filename_to_abs(d) for d in self.__include_dirs]
109109
if objects:
110-
objects = map(self._filename_to_abs, objects)
110+
objects = [self._filename_to_abs(o) for o in objects]
111111
else:
112112
objects = []
113113
if build_temp:

Lib/distutils/text_file.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def unreadline(self, line):
292292
continues on next line
293293
"""
294294
# result 1: no fancy options
295-
result1 = map(lambda x: x + "\n", test_data.split("\n")[0:-1])
295+
result1 = [x + "\n" for x in test_data.split("\n")[:-1]]
296296

297297
# result 2: just strip comments
298298
result2 = ["\n",
@@ -357,4 +357,5 @@ def test_input(count, description, file, expected_result):
357357
join_lines=1, rstrip_ws=1, collapse_join=1)
358358
test_input(6, "join lines with collapsing", in_file, result6)
359359

360+
del in_file
360361
os.remove(filename)

0 commit comments

Comments
 (0)