Index: Lib/distutils/cmd.py =================================================================== --- Lib/distutils/cmd.py (révision 66667) +++ Lib/distutils/cmd.py (copie de travail) @@ -8,8 +8,7 @@ __revision__ = "$Id$" -import sys, os, string, re -from types import * +import sys, os, re from distutils.errors import * from distutils import util, dir_util, file_util, archive_util, dep_util from distutils import log @@ -166,7 +165,7 @@ print indent + header indent = indent + " " for (option, _, _) in self.user_options: - option = string.translate(option, longopt_xlate) + option = option.translate(longopt_xlate) if option[-1] == "=": option = option[:-1] value = getattr(self, option) @@ -222,7 +221,7 @@ if val is None: setattr(self, option, default) return default - elif type(val) is not StringType: + elif isinstance(val, str): raise DistutilsOptionError, \ "'%s' must be a %s (got `%s`)" % (option, what, val) return val @@ -242,14 +241,17 @@ val = getattr(self, option) if val is None: return - elif type(val) is StringType: + elif isinstance(val, str): setattr(self, option, re.split(r',\s*|\s+', val)) else: - if type(val) is ListType: - types = map(type, val) - ok = (types == [StringType] * len(val)) + if isinstance(val, list): + ok = True + for item in val: + if not isinstance(item, str): + ok = False + break else: - ok = 0 + ok = False if not ok: raise DistutilsOptionError, \ @@ -415,15 +417,15 @@ """ if exec_msg is None: exec_msg = "generating %s from %s" % \ - (outfile, string.join(infiles, ', ')) + (outfile, ', '.join(infiles)) if skip_msg is None: skip_msg = "skipping %s (inputs unchanged)" % outfile # Allow 'infiles' to be a single string - if type(infiles) is StringType: + if isinstance(infiles, str): infiles = (infiles,) - elif type(infiles) not in (ListType, TupleType): + elif not isinstance(infiles, list) and isinstance(infiles, tuple): raise TypeError, \ "'infiles' must be a string, or a list or tuple of strings"