diff options
author | Guido van Rossum <guido@python.org> | 2007-10-16 18:12:55 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-10-16 18:12:55 (GMT) |
commit | 3172c5d263eeffff1e89d03d79be3ccc1d60fbde (patch) | |
tree | a35e103b36b684c4682ded57236199d6a0ecee4b /Lib/distutils | |
parent | 60d241f135f10312f5a638846659d7e471f6cac9 (diff) | |
download | cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.zip cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.tar.gz cpython-3172c5d263eeffff1e89d03d79be3ccc1d60fbde.tar.bz2 |
Patch# 1258 by Christian Heimes: kill basestring.
I like this because it makes the code shorter! :-)
Diffstat (limited to 'Lib/distutils')
-rw-r--r-- | Lib/distutils/ccompiler.py | 12 | ||||
-rw-r--r-- | Lib/distutils/cmd.py | 8 | ||||
-rw-r--r-- | Lib/distutils/command/build_clib.py | 4 | ||||
-rw-r--r-- | Lib/distutils/command/build_ext.py | 10 | ||||
-rw-r--r-- | Lib/distutils/command/build_py.py | 2 | ||||
-rw-r--r-- | Lib/distutils/command/config.py | 8 | ||||
-rw-r--r-- | Lib/distutils/command/install.py | 2 | ||||
-rw-r--r-- | Lib/distutils/command/install_data.py | 2 | ||||
-rw-r--r-- | Lib/distutils/dir_util.py | 2 | ||||
-rw-r--r-- | Lib/distutils/dist.py | 6 | ||||
-rw-r--r-- | Lib/distutils/extension.py | 4 | ||||
-rw-r--r-- | Lib/distutils/fancy_getopt.py | 4 | ||||
-rw-r--r-- | Lib/distutils/filelist.py | 2 | ||||
-rw-r--r-- | Lib/distutils/unixccompiler.py | 2 |
14 files changed, 34 insertions, 34 deletions
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index c33e5ab..f4edb7c 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -154,7 +154,7 @@ class CCompiler: self.set_executable(key, value) def set_executable(self, key, value): - if isinstance(value, basestring): + if isinstance(value, str): setattr(self, key, split_quoted(value)) else: setattr(self, key, value) @@ -175,8 +175,8 @@ class CCompiler: for defn in definitions: if not (isinstance(defn, tuple) and (len(defn) in (1, 2) and - (isinstance (defn[1], basestring) or defn[1] is None)) and - isinstance (defn[0], basestring)): + (isinstance (defn[1], str) or defn[1] is None)) and + isinstance (defn[0], str)): raise TypeError(("invalid macro definition '%s': " % defn) + \ "must be tuple (string,), (string, string), or " + \ "(string, None)") @@ -318,7 +318,7 @@ class CCompiler: """ if outdir is None: outdir = self.output_dir - elif not isinstance(outdir, basestring): + elif not isinstance(outdir, str): raise TypeError("'output_dir' must be a string or None") if macros is None: @@ -415,7 +415,7 @@ class CCompiler: """ if output_dir is None: output_dir = self.output_dir - elif not isinstance(output_dir, basestring): + elif not isinstance(output_dir, str): raise TypeError("'output_dir' must be a string or None") if macros is None: @@ -494,7 +494,7 @@ class CCompiler: if output_dir is None: output_dir = self.output_dir - elif not isinstance(output_dir, basestring): + elif not isinstance(output_dir, str): raise TypeError("'output_dir' must be a string or None") return (objects, output_dir) diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py index 66940f7..bd560a6 100644 --- a/Lib/distutils/cmd.py +++ b/Lib/distutils/cmd.py @@ -213,7 +213,7 @@ class Command: if val is None: setattr(self, option, default) return default - elif not isinstance(val, basestring): + elif not isinstance(val, str): raise DistutilsOptionError("'%s' must be a %s (got `%s`)" % (option, what, val)) return val @@ -233,11 +233,11 @@ class Command: val = getattr(self, option) if val is None: return - elif isinstance(val, basestring): + elif isinstance(val, str): setattr(self, option, re.split(r',\s*|\s+', val)) else: if isinstance(val, list): - ok = all(isinstance(v, basestring) for v in val) + ok = all(isinstance(v, str) for v in val) else: ok = False if not ok: @@ -390,7 +390,7 @@ class Command: # Allow 'infiles' to be a single string - if isinstance(infiles, basestring): + if isinstance(infiles, str): infiles = (infiles,) elif not isinstance(infiles, (list, tuple)): raise TypeError( diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py index 5f95207..34f4983 100644 --- a/Lib/distutils/command/build_clib.py +++ b/Lib/distutils/command/build_clib.py @@ -86,7 +86,7 @@ class build_clib(Command): if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - if isinstance(self.include_dirs, basestring): + if isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) # XXX same as for build_ext -- what about 'self.define' and @@ -134,7 +134,7 @@ class build_clib(Command): raise DistutilsSetupError( "each element of 'libraries' must a 2-tuple") - if isinstance(lib[0], basestring): + if isinstance(lib[0], str): raise DistutilsSetupError( "first element of each tuple in 'libraries' " "must be a string (the library name)") diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index a439c49..ddf8f72 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -133,7 +133,7 @@ class build_ext(Command): plat_py_include = sysconfig.get_python_inc(plat_specific=1) if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - if isinstance(self.include_dirs, basestring): + if isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) # Put the Python "system" include dir at the end, so that @@ -142,7 +142,7 @@ class build_ext(Command): if plat_py_include != py_include: self.include_dirs.append(plat_py_include) - if isinstance(self.libraries, basestring): + if isinstance(self.libraries, str): self.libraries = [self.libraries] # Life is easier if we're not forever checking for None, so @@ -151,12 +151,12 @@ class build_ext(Command): self.libraries = [] if self.library_dirs is None: self.library_dirs = [] - elif isinstance(self.library_dirs, basestring): + elif isinstance(self.library_dirs, str): self.library_dirs = self.library_dirs.split(os.pathsep) if self.rpath is None: self.rpath = [] - elif isinstance(self.rpath, basestring): + elif isinstance(self.rpath, str): self.rpath = self.rpath.split(os.pathsep) # for extensions under windows use different directories @@ -309,7 +309,7 @@ class build_ext(Command): "each element of 'ext_modules' option must be an " "Extension instance or 2-tuple") - if not (isinstance(ext_name, basestring) and + if not (isinstance(ext_name, str) and extension_name_re.match(ext_name)): raise DistutilsSetupError( "first element of each tuple in 'ext_modules' " diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py index 454424f..63ced4b 100644 --- a/Lib/distutils/command/build_py.py +++ b/Lib/distutils/command/build_py.py @@ -325,7 +325,7 @@ class build_py (Command): return outputs def build_module(self, module, module_file, package): - if isinstance(package, basestring): + if isinstance(package, str): package = package.split('.') elif not isinstance(package, (list, tuple)): raise TypeError( diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py index a601234..34f9188 100644 --- a/Lib/distutils/command/config.py +++ b/Lib/distutils/command/config.py @@ -69,17 +69,17 @@ class config(Command): def finalize_options(self): if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - elif isinstance(self.include_dirs, basestring): + elif isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) if self.libraries is None: self.libraries = [] - elif isinstance(self.libraries, basestring): + elif isinstance(self.libraries, str): self.libraries = [self.libraries] if self.library_dirs is None: self.library_dirs = [] - elif isinstance(self.library_dirs, basestring): + elif isinstance(self.library_dirs, str): self.library_dirs = self.library_dirs.split(os.pathsep) def run(self): @@ -204,7 +204,7 @@ class config(Command): self._check_compiler() (src, out) = self._preprocess(body, headers, include_dirs, lang) - if isinstance(pattern, basestring): + if isinstance(pattern, str): pattern = re.compile(pattern) file = open(out) diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py index f1ebcbf..b768663 100644 --- a/Lib/distutils/command/install.py +++ b/Lib/distutils/command/install.py @@ -449,7 +449,7 @@ class install (Command): self.extra_path = self.distribution.extra_path if self.extra_path is not None: - if isinstance(self.extra_path, basestring): + if isinstance(self.extra_path, str): self.extra_path = self.extra_path.split(',') if len(self.extra_path) == 1: diff --git a/Lib/distutils/command/install_data.py b/Lib/distutils/command/install_data.py index 2fbac63..06a70b4 100644 --- a/Lib/distutils/command/install_data.py +++ b/Lib/distutils/command/install_data.py @@ -45,7 +45,7 @@ class install_data(Command): def run(self): self.mkpath(self.install_dir) for f in self.data_files: - if isinstance(f, basestring): + if isinstance(f, str): # it's a simple file, so copy it f = convert_path(f) if self.warn_dir: diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py index 30e352d..1f0d49c 100644 --- a/Lib/distutils/dir_util.py +++ b/Lib/distutils/dir_util.py @@ -28,7 +28,7 @@ def mkpath (name, mode=0o777, verbose=0, dry_run=0): global _path_created # Detect a common bug -- name is None - if not isinstance(name, basestring): + if not isinstance(name, str): raise DistutilsInternalError( "mkpath: 'name' must be a string (got %r)" % (name,)) diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py index 631df48..ade2ab7 100644 --- a/Lib/distutils/dist.py +++ b/Lib/distutils/dist.py @@ -580,13 +580,13 @@ Common commands: (see '--help-commands' for more) keywords = self.metadata.keywords if keywords is not None: - if isinstance(keywords, basestring): + if isinstance(keywords, str): keywordlist = keywords.split(',') self.metadata.keywords = [x.strip() for x in keywordlist] platforms = self.metadata.platforms if platforms is not None: - if isinstance(platforms, basestring): + if isinstance(platforms, str): platformlist = platforms.split(',') self.metadata.platforms = [x.strip() for x in platformlist] @@ -874,7 +874,7 @@ Common commands: (see '--help-commands' for more) neg_opt = {} try: - is_string = isinstance(value, basestring) + is_string = isinstance(value, str) if option in neg_opt and is_string: setattr(command_obj, neg_opt[option], not strtobool(value)) elif option in bool_opts and is_string: diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py index 7f5954e..b271816 100644 --- a/Lib/distutils/extension.py +++ b/Lib/distutils/extension.py @@ -102,9 +102,9 @@ class Extension: language=None, **kw # To catch unknown keywords ): - assert isinstance(name, basestring), "'name' must be a string" + assert isinstance(name, str), "'name' must be a string" assert (isinstance(sources, list) and - all(isinstance(v, basestring) for v in sources)), \ + all(isinstance(v, str) for v in sources)), \ "'sources' must be a list of strings" self.name = name diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py index b3231c3..72441fb 100644 --- a/Lib/distutils/fancy_getopt.py +++ b/Lib/distutils/fancy_getopt.py @@ -154,12 +154,12 @@ class FancyGetopt: raise ValueError("invalid option tuple: %r" % (option,)) # Type- and value-check the option names - if not isinstance(long, basestring) or len(long) < 2: + if not isinstance(long, str) or len(long) < 2: raise DistutilsGetoptError(("invalid long option '%s': " "must be a string of length >= 2") % long) if (not ((short is None) or - (isinstance(short, basestring) and len(short) == 1))): + (isinstance(short, str) and len(short) == 1))): raise DistutilsGetoptError("invalid short option '%s': " "must a single character or None" % short) diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py index 8f80107..6506c30 100644 --- a/Lib/distutils/filelist.py +++ b/Lib/distutils/filelist.py @@ -301,7 +301,7 @@ def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0): or just returned as-is (assumes it's a regex object). """ if is_regex: - if isinstance(pattern, basestring): + if isinstance(pattern, str): return re.compile(pattern) else: return pattern diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py index 91d0dff..ee975e1 100644 --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -211,7 +211,7 @@ class UnixCCompiler(CCompiler): lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) - if not isinstance(output_dir, (basestring, type(None))): + if not isinstance(output_dir, (str, type(None))): raise TypeError("'output_dir' must be a string or None") if output_dir is not None: output_filename = os.path.join(output_dir, output_filename) |