[Python-checkins] r76956 - in python/trunk/Lib/distutils: bcppcompiler.py ccompiler.py command/bdist.py command/bdist_msi.py command/bdist_rpm.py command/bdist_wininst.py command/build_clib.py command/build_ext.py command/build_py.py command/config.py command/register.py command/sdist.py command/upload.py config.py core.py cygwinccompiler.py dir_util.py dist.py emxccompiler.py extension.py fancy_getopt.py msvc9compiler.py msvccompiler.py text_file.py

tarek.ziade python-checkins at python.org
Mon Dec 21 02:22:47 CET 2009


Author: tarek.ziade
Date: Mon Dec 21 02:22:46 2009
New Revision: 76956

Log:
massive import cleaning in Distutils

Modified:
   python/trunk/Lib/distutils/bcppcompiler.py
   python/trunk/Lib/distutils/ccompiler.py
   python/trunk/Lib/distutils/command/bdist.py
   python/trunk/Lib/distutils/command/bdist_msi.py
   python/trunk/Lib/distutils/command/bdist_rpm.py
   python/trunk/Lib/distutils/command/bdist_wininst.py
   python/trunk/Lib/distutils/command/build_clib.py
   python/trunk/Lib/distutils/command/build_ext.py
   python/trunk/Lib/distutils/command/build_py.py
   python/trunk/Lib/distutils/command/config.py
   python/trunk/Lib/distutils/command/register.py
   python/trunk/Lib/distutils/command/sdist.py
   python/trunk/Lib/distutils/command/upload.py
   python/trunk/Lib/distutils/config.py
   python/trunk/Lib/distutils/core.py
   python/trunk/Lib/distutils/cygwinccompiler.py
   python/trunk/Lib/distutils/dir_util.py
   python/trunk/Lib/distutils/dist.py
   python/trunk/Lib/distutils/emxccompiler.py
   python/trunk/Lib/distutils/extension.py
   python/trunk/Lib/distutils/fancy_getopt.py
   python/trunk/Lib/distutils/msvc9compiler.py
   python/trunk/Lib/distutils/msvccompiler.py
   python/trunk/Lib/distutils/text_file.py

Modified: python/trunk/Lib/distutils/bcppcompiler.py
==============================================================================
--- python/trunk/Lib/distutils/bcppcompiler.py	(original)
+++ python/trunk/Lib/distutils/bcppcompiler.py	Mon Dec 21 02:22:46 2009
@@ -13,13 +13,11 @@
 
 __revision__ = "$Id$"
 
-
 import os
-from distutils.errors import \
-     DistutilsExecError, DistutilsPlatformError, \
-     CompileError, LibError, LinkError, UnknownFileError
-from distutils.ccompiler import \
-     CCompiler, gen_preprocess_options, gen_lib_options
+
+from distutils.errors import (DistutilsExecError, CompileError, LibError,
+                              LinkError, UnknownFileError)
+from distutils.ccompiler import CCompiler, gen_preprocess_options
 from distutils.file_util import write_file
 from distutils.dep_util import newer
 from distutils import log

Modified: python/trunk/Lib/distutils/ccompiler.py
==============================================================================
--- python/trunk/Lib/distutils/ccompiler.py	(original)
+++ python/trunk/Lib/distutils/ccompiler.py	Mon Dec 21 02:22:46 2009
@@ -5,9 +5,11 @@
 
 __revision__ = "$Id$"
 
-import sys, os, re
-from types import *
-from distutils.errors import *
+import sys
+import os
+import re
+
+from distutils.errors import CompileError, LinkError, UnknownFileError
 from distutils.spawn import spawn
 from distutils.file_util import move_file
 from distutils.dir_util import mkpath
@@ -165,7 +167,7 @@
     # set_executables ()
 
     def set_executable(self, key, value):
-        if type(value) is StringType:
+        if isinstance(value, str):
             setattr(self, key, split_quoted(value))
         else:
             setattr(self, key, value)
@@ -187,11 +189,11 @@
         nothing if all definitions are OK, raise TypeError otherwise.
         """
         for defn in definitions:
-            if not (type (defn) is TupleType and
+            if not (isinstance(defn, tuple) and
                     (len (defn) == 1 or
                      (len (defn) == 2 and
-                      (type (defn[1]) is StringType or defn[1] is None))) and
-                    type (defn[0]) is StringType):
+                      (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 " + \
@@ -341,19 +343,19 @@
         """
         if outdir is None:
             outdir = self.output_dir
-        elif type(outdir) is not StringType:
+        elif not isinstance(outdir, str):
             raise TypeError, "'output_dir' must be a string or None"
 
         if macros is None:
             macros = self.macros
-        elif type(macros) is ListType:
+        elif isinstance(macros, list):
             macros = macros + (self.macros or [])
         else:
             raise TypeError, "'macros' (if supplied) must be a list of tuples"
 
         if incdirs is None:
             incdirs = self.include_dirs
-        elif type(incdirs) in (ListType, TupleType):
+        elif isinstance(incdirs, (list, tuple)):
             incdirs = list(incdirs) + (self.include_dirs or [])
         else:
             raise TypeError, \
@@ -444,14 +446,14 @@
 
         if macros is None:
             macros = self.macros
-        elif type (macros) is ListType:
+        elif isinstance(macros, list):
             macros = macros + (self.macros or [])
         else:
             raise TypeError, "'macros' (if supplied) must be a list of tuples"
 
         if include_dirs is None:
             include_dirs = self.include_dirs
-        elif type (include_dirs) in (ListType, TupleType):
+        elif isinstance(include_dirs, (list, tuple)):
             include_dirs = list (include_dirs) + (self.include_dirs or [])
         else:
             raise TypeError, \
@@ -517,14 +519,14 @@
         None, replace with self.output_dir.  Return fixed versions of
         'objects' and 'output_dir'.
         """
-        if type (objects) not in (ListType, TupleType):
+        if not isinstance(objects, (list, tuple)):
             raise TypeError, \
                   "'objects' must be a list or tuple of strings"
         objects = list (objects)
 
         if output_dir is None:
             output_dir = self.output_dir
-        elif type (output_dir) is not StringType:
+        elif not isinstance(output_dir, str):
             raise TypeError, "'output_dir' must be a string or None"
 
         return (objects, output_dir)
@@ -539,7 +541,7 @@
         """
         if libraries is None:
             libraries = self.libraries
-        elif type (libraries) in (ListType, TupleType):
+        elif isinstance(libraries, (list, tuple)):
             libraries = list (libraries) + (self.libraries or [])
         else:
             raise TypeError, \
@@ -547,7 +549,7 @@
 
         if library_dirs is None:
             library_dirs = self.library_dirs
-        elif type (library_dirs) in (ListType, TupleType):
+        elif isinstance(library_dirs, (list, tuple)):
             library_dirs = list (library_dirs) + (self.library_dirs or [])
         else:
             raise TypeError, \
@@ -555,7 +557,7 @@
 
         if runtime_library_dirs is None:
             runtime_library_dirs = self.runtime_library_dirs
-        elif type (runtime_library_dirs) in (ListType, TupleType):
+        elif isinstance(runtime_library_dirs, (list, tuple)):
             runtime_library_dirs = (list (runtime_library_dirs) +
                                     (self.runtime_library_dirs or []))
         else:
@@ -587,7 +589,7 @@
         """Detect the language of a given file, or list of files. Uses
         language_map, and language_order to do the job.
         """
-        if type(sources) is not ListType:
+        if not isinstance(sources, list):
             sources = [sources]
         lang = None
         index = len(self.language_order)
@@ -1194,7 +1196,7 @@
     pp_opts = []
     for macro in macros:
 
-        if not (type (macro) is TupleType and
+        if not (isinstance(macro, tuple) and
                 1 <= len (macro) <= 2):
             raise TypeError, \
                   ("bad macro definition '%s': " +

Modified: python/trunk/Lib/distutils/command/bdist.py
==============================================================================
--- python/trunk/Lib/distutils/command/bdist.py	(original)
+++ python/trunk/Lib/distutils/command/bdist.py	Mon Dec 21 02:22:46 2009
@@ -6,9 +6,9 @@
 __revision__ = "$Id$"
 
 import os
-from types import *
+
 from distutils.core import Command
-from distutils.errors import *
+from distutils.errors import DistutilsPlatformError, DistutilsOptionError
 from distutils.util import get_platform
 
 
@@ -16,7 +16,7 @@
     """Print list of available formats (arguments to "--format" option).
     """
     from distutils.fancy_getopt import FancyGetopt
-    formats=[]
+    formats = []
     for format in bdist.format_commands:
         formats.append(("formats=" + format, None,
                         bdist.format_command[format][1]))

Modified: python/trunk/Lib/distutils/command/bdist_msi.py
==============================================================================
--- python/trunk/Lib/distutils/command/bdist_msi.py	(original)
+++ python/trunk/Lib/distutils/command/bdist_msi.py	Mon Dec 21 02:22:46 2009
@@ -28,7 +28,6 @@
         default, cancel, bitmap=true)"""
         Dialog.__init__(self, *args)
         ruler = self.h - 36
-        bmwidth = 152*ruler/328
         #if kw.get("bitmap", True):
         #    self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
         self.line("BottomLine", 0, ruler, self.w, 0)
@@ -420,7 +419,6 @@
         # see "Dialog Style Bits"
         modal = 3      # visible | modal
         modeless = 1   # visible
-        track_disk_space = 32
 
         # UI customization properties
         add_data(db, "Property",

Modified: python/trunk/Lib/distutils/command/bdist_rpm.py
==============================================================================
--- python/trunk/Lib/distutils/command/bdist_rpm.py	(original)
+++ python/trunk/Lib/distutils/command/bdist_rpm.py	Mon Dec 21 02:22:46 2009
@@ -5,14 +5,15 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string
-from types import *
+import sys
+import os
+import string
+
 from distutils.core import Command
 from distutils.debug import DEBUG
-from distutils.util import get_platform
 from distutils.file_util import write_file
-from distutils.errors import *
-from distutils.sysconfig import get_python_version
+from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
+                              DistutilsFileError, DistutilsExecError)
 from distutils import log
 
 class bdist_rpm (Command):
@@ -225,7 +226,7 @@
                                         self.distribution.get_contact_email()))
         self.ensure_string('packager')
         self.ensure_string_list('doc_files')
-        if type(self.doc_files) is ListType:
+        if isinstance(self.doc_files, list):
             for readme in ('README', 'README.txt'):
                 if os.path.exists(readme) and readme not in self.doc_files:
                     self.doc_files.append(readme)
@@ -444,7 +445,7 @@
                       'Obsoletes',
                       ):
             val = getattr(self, string.lower(field))
-            if type(val) is ListType:
+            if isinstance(val, list):
                 spec_file.append('%s: %s' % (field, string.join(val)))
             elif val is not None:
                 spec_file.append('%s: %s' % (field, val))

Modified: python/trunk/Lib/distutils/command/bdist_wininst.py
==============================================================================
--- python/trunk/Lib/distutils/command/bdist_wininst.py	(original)
+++ python/trunk/Lib/distutils/command/bdist_wininst.py	Mon Dec 21 02:22:46 2009
@@ -5,11 +5,14 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string
+import sys
+import os
+import string
+
 from distutils.core import Command
 from distutils.util import get_platform
-from distutils.dir_util import create_tree, remove_tree
-from distutils.errors import *
+from distutils.dir_util import remove_tree
+from distutils.errors import DistutilsOptionError, DistutilsPlatformError
 from distutils.sysconfig import get_python_version
 from distutils import log
 

Modified: python/trunk/Lib/distutils/command/build_clib.py
==============================================================================
--- python/trunk/Lib/distutils/command/build_clib.py	(original)
+++ python/trunk/Lib/distutils/command/build_clib.py	Mon Dec 21 02:22:46 2009
@@ -18,7 +18,7 @@
 
 import os
 from distutils.core import Command
-from distutils.errors import *
+from distutils.errors import DistutilsSetupError
 from distutils.sysconfig import customize_compiler
 from distutils import log
 

Modified: python/trunk/Lib/distutils/command/build_ext.py
==============================================================================
--- python/trunk/Lib/distutils/command/build_ext.py	(original)
+++ python/trunk/Lib/distutils/command/build_ext.py	Mon Dec 21 02:22:46 2009
@@ -10,7 +10,8 @@
 from warnings import warn
 
 from distutils.core import Command
-from distutils.errors import *
+from distutils.errors import (CCompilerError, DistutilsError, CompileError,
+                              DistutilsSetupError, DistutilsPlatformError)
 from distutils.sysconfig import customize_compiler, get_python_version
 from distutils.dep_util import newer_group
 from distutils.extension import Extension

Modified: python/trunk/Lib/distutils/command/build_py.py
==============================================================================
--- python/trunk/Lib/distutils/command/build_py.py	(original)
+++ python/trunk/Lib/distutils/command/build_py.py	Mon Dec 21 02:22:46 2009
@@ -133,7 +133,6 @@
 
     def build_package_data(self):
         """Copy data files into build directory"""
-        lastdir = None
         for package, src_dir, build_dir, filenames in self.data_files:
             for filename in filenames:
                 target = os.path.join(build_dir, filename)

Modified: python/trunk/Lib/distutils/command/config.py
==============================================================================
--- python/trunk/Lib/distutils/command/config.py	(original)
+++ python/trunk/Lib/distutils/command/config.py	Mon Dec 21 02:22:46 2009
@@ -11,7 +11,8 @@
 
 __revision__ = "$Id$"
 
-import sys, os, re
+import os
+import re
 
 from distutils.core import Command
 from distutils.errors import DistutilsExecError

Modified: python/trunk/Lib/distutils/command/register.py
==============================================================================
--- python/trunk/Lib/distutils/command/register.py	(original)
+++ python/trunk/Lib/distutils/command/register.py	Mon Dec 21 02:22:46 2009
@@ -7,12 +7,13 @@
 
 __revision__ = "$Id$"
 
-import os, string, urllib2, getpass, urlparse
+import urllib2
+import getpass
+import urlparse
 import StringIO
 from warnings import warn
 
 from distutils.core import PyPIRCCommand
-from distutils.errors import *
 from distutils import log
 
 class register(PyPIRCCommand):

Modified: python/trunk/Lib/distutils/command/sdist.py
==============================================================================
--- python/trunk/Lib/distutils/command/sdist.py	(original)
+++ python/trunk/Lib/distutils/command/sdist.py	Mon Dec 21 02:22:46 2009
@@ -4,16 +4,17 @@
 
 __revision__ = "$Id$"
 
-import os, string
+import os
+import string
 import sys
-from types import *
 from glob import glob
 from warnings import warn
 
 from distutils.core import Command
 from distutils import dir_util, dep_util, file_util, archive_util
 from distutils.text_file import TextFile
-from distutils.errors import *
+from distutils.errors import (DistutilsPlatformError, DistutilsOptionError,
+                              DistutilsTemplateError)
 from distutils.filelist import FileList
 from distutils import log
 from distutils.util import convert_path
@@ -256,7 +257,7 @@
 
         standards = [('README', 'README.txt'), self.distribution.script_name]
         for fn in standards:
-            if type(fn) is TupleType:
+            if isinstance(fn, tuple):
                 alts = fn
                 got_it = 0
                 for fn in alts:

Modified: python/trunk/Lib/distutils/command/upload.py
==============================================================================
--- python/trunk/Lib/distutils/command/upload.py	(original)
+++ python/trunk/Lib/distutils/command/upload.py	Mon Dec 21 02:22:46 2009
@@ -1,7 +1,6 @@
 """distutils.command.upload
 
 Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
-import sys
 import os
 import socket
 import platform
@@ -9,10 +8,9 @@
 from base64 import standard_b64encode
 import urlparse
 import cStringIO as StringIO
-from ConfigParser import ConfigParser
 from hashlib import md5
 
-from distutils.errors import *
+from distutils.errors import DistutilsOptionError
 from distutils.core import PyPIRCCommand
 from distutils.spawn import spawn
 from distutils import log

Modified: python/trunk/Lib/distutils/config.py
==============================================================================
--- python/trunk/Lib/distutils/config.py	(original)
+++ python/trunk/Lib/distutils/config.py	Mon Dec 21 02:22:46 2009
@@ -4,7 +4,6 @@
 that uses .pypirc in the distutils.command package.
 """
 import os
-import sys
 from ConfigParser import ConfigParser
 
 from distutils.cmd import Command
@@ -60,8 +59,6 @@
         if os.path.exists(rc):
             self.announce('Using PyPI login from %s' % rc)
             repository = self.repository or self.DEFAULT_REPOSITORY
-            realm = self.realm or self.DEFAULT_REALM
-
             config = ConfigParser()
             config.read(rc)
             sections = config.sections()

Modified: python/trunk/Lib/distutils/core.py
==============================================================================
--- python/trunk/Lib/distutils/core.py	(original)
+++ python/trunk/Lib/distutils/core.py	Mon Dec 21 02:22:46 2009
@@ -8,10 +8,12 @@
 
 __revision__ = "$Id$"
 
-import sys, os
+import sys
+import os
 
 from distutils.debug import DEBUG
-from distutils.errors import *
+from distutils.errors import (DistutilsSetupError, DistutilsArgError,
+                              DistutilsError, CCompilerError)
 from distutils.util import grok_environment_error
 
 # Mainly import these so setup scripts can "from distutils.core import" them.
@@ -31,7 +33,7 @@
    or: %(script)s cmd --help
 """
 
-def gen_usage (script_name):
+def gen_usage(script_name):
     script = os.path.basename(script_name)
     return USAGE % vars()
 
@@ -56,7 +58,7 @@
                       'extra_objects', 'extra_compile_args', 'extra_link_args',
                       'swig_opts', 'export_symbols', 'depends', 'language')
 
-def setup (**attrs):
+def setup(**attrs):
     """The gateway to the Distutils: do everything your setup script needs
     to do, in a highly flexible and user-driven way.  Briefly: create a
     Distribution instance; find and parse config files; parse the command
@@ -168,10 +170,8 @@
 
     return dist
 
-# setup ()
 
-
-def run_setup (script_name, script_args=None, stop_after="run"):
+def run_setup(script_name, script_args=None, stop_after="run"):
     """Run a setup script in a somewhat controlled environment, and
     return the Distribution instance that drives things.  This is useful
     if you need to find out the distribution meta-data (passed as
@@ -235,7 +235,4 @@
 
     # I wonder if the setup script's namespace -- g and l -- would be of
     # any interest to callers?
-    #print "_setup_distribution:", _setup_distribution
     return _setup_distribution
-
-# run_setup ()

Modified: python/trunk/Lib/distutils/cygwinccompiler.py
==============================================================================
--- python/trunk/Lib/distutils/cygwinccompiler.py	(original)
+++ python/trunk/Lib/distutils/cygwinccompiler.py	Mon Dec 21 02:22:46 2009
@@ -53,11 +53,9 @@
 import re
 from warnings import warn
 
-from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
 from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
-from distutils import log
 from distutils.util import get_compiler_versions
 
 def get_msvcr():

Modified: python/trunk/Lib/distutils/dir_util.py
==============================================================================
--- python/trunk/Lib/distutils/dir_util.py	(original)
+++ python/trunk/Lib/distutils/dir_util.py	Mon Dec 21 02:22:46 2009
@@ -4,7 +4,7 @@
 
 __revision__ = "$Id$"
 
-import os, sys
+import os
 from distutils.errors import DistutilsFileError, DistutilsInternalError
 from distutils import log
 

Modified: python/trunk/Lib/distutils/dist.py
==============================================================================
--- python/trunk/Lib/distutils/dist.py	(original)
+++ python/trunk/Lib/distutils/dist.py	Mon Dec 21 02:22:46 2009
@@ -14,7 +14,8 @@
 except ImportError:
     warnings = None
 
-from distutils.errors import *
+from distutils.errors import (DistutilsOptionError, DistutilsArgError,
+                              DistutilsModuleError, DistutilsClassError)
 from distutils.fancy_getopt import FancyGetopt, translate_longopt
 from distutils.util import check_environ, strtobool, rfc822_escape
 from distutils import log

Modified: python/trunk/Lib/distutils/emxccompiler.py
==============================================================================
--- python/trunk/Lib/distutils/emxccompiler.py	(original)
+++ python/trunk/Lib/distutils/emxccompiler.py	Mon Dec 21 02:22:46 2009
@@ -24,11 +24,9 @@
 import os, sys, copy
 from warnings import warn
 
-from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
 from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
-from distutils import log
 from distutils.util import get_compiler_versions
 
 class EMXCCompiler (UnixCCompiler):

Modified: python/trunk/Lib/distutils/extension.py
==============================================================================
--- python/trunk/Lib/distutils/extension.py	(original)
+++ python/trunk/Lib/distutils/extension.py	Mon Dec 21 02:22:46 2009
@@ -6,7 +6,6 @@
 __revision__ = "$Id$"
 
 import os
-import sys
 import warnings
 
 # This class is really only used by the "build_ext" command, so it might

Modified: python/trunk/Lib/distutils/fancy_getopt.py
==============================================================================
--- python/trunk/Lib/distutils/fancy_getopt.py	(original)
+++ python/trunk/Lib/distutils/fancy_getopt.py	Mon Dec 21 02:22:46 2009
@@ -10,10 +10,11 @@
 
 __revision__ = "$Id$"
 
-import sys, string, re
-from types import *
+import sys
+import string
+import re
 import getopt
-from distutils.errors import *
+from distutils.errors import DistutilsGetoptError, DistutilsArgError
 
 # Much like command_re in distutils.core, this is close to but not quite
 # the same as a Python NAME -- except, in the spirit of most GNU
@@ -117,7 +118,7 @@
 
 
     def _check_alias_dict (self, aliases, what):
-        assert type(aliases) is DictionaryType
+        assert isinstance(aliases, dict)
         for (alias, opt) in aliases.items():
             if alias not in self.option_index:
                 raise DistutilsGetoptError, \
@@ -164,13 +165,13 @@
                 raise ValueError, "invalid option tuple: %r" % (option,)
 
             # Type- and value-check the option names
-            if type(long) is not StringType 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
-                     (type(short) is StringType and len(short) == 1))):
+                     (isinstance(short, str) and len(short) == 1))):
                 raise DistutilsGetoptError, \
                       ("invalid short option '%s': "
                        "must a single character or None") % short
@@ -464,10 +465,8 @@
 
     return lines
 
-# wrap_text ()
 
-
-def translate_longopt (opt):
+def translate_longopt(opt):
     """Convert a long option name to a valid Python identifier by
     changing "-" to "_".
     """
@@ -483,18 +482,3 @@
         'options' will be initialized to None."""
         for opt in options:
             setattr(self, opt, None)
-
-# class OptionDummy
-
-
-if __name__ == "__main__":
-    text = """\
-Tra-la-la, supercalifragilisticexpialidocious.
-How *do* you spell that odd word, anyways?
-(Someone ask Mary -- she'll know [or she'll
-say, "How should I know?"].)"""
-
-    for w in (10, 20, 30, 40):
-        print "width: %d" % w
-        print string.join(wrap_text(text, w), "\n")
-        print

Modified: python/trunk/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/trunk/Lib/distutils/msvc9compiler.py	(original)
+++ python/trunk/Lib/distutils/msvc9compiler.py	Mon Dec 21 02:22:46 2009
@@ -19,10 +19,9 @@
 import sys
 import re
 
-from distutils.errors import DistutilsExecError, DistutilsPlatformError, \
-                             CompileError, LibError, LinkError
-from distutils.ccompiler import CCompiler, gen_preprocess_options, \
-                                gen_lib_options
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
+                              CompileError, LibError, LinkError)
+from distutils.ccompiler import CCompiler, gen_lib_options
 from distutils import log
 from distutils.util import get_platform
 

Modified: python/trunk/Lib/distutils/msvccompiler.py
==============================================================================
--- python/trunk/Lib/distutils/msvccompiler.py	(original)
+++ python/trunk/Lib/distutils/msvccompiler.py	Mon Dec 21 02:22:46 2009
@@ -10,12 +10,13 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string
-from distutils.errors import \
-     DistutilsExecError, DistutilsPlatformError, \
-     CompileError, LibError, LinkError
-from distutils.ccompiler import \
-     CCompiler, gen_preprocess_options, gen_lib_options
+import sys
+import os
+import string
+
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
+                              CompileError, LibError, LinkError)
+from distutils.ccompiler import CCompiler, gen_lib_options
 from distutils import log
 
 _can_read_reg = 0
@@ -127,7 +128,7 @@
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
             else:
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
-        except KeyError, exc: #
+        except KeyError:
             raise DistutilsPlatformError, \
                   ("""Python was built with Visual Studio 2003;
 extensions must be built with a compiler than can generate compatible binaries.

Modified: python/trunk/Lib/distutils/text_file.py
==============================================================================
--- python/trunk/Lib/distutils/text_file.py	(original)
+++ python/trunk/Lib/distutils/text_file.py	Mon Dec 21 02:22:46 2009
@@ -6,8 +6,7 @@
 
 __revision__ = "$Id$"
 
-from types import *
-import sys, os, string
+import sys
 
 
 class TextFile:
@@ -137,12 +136,12 @@
         if line is None:
             line = self.current_line
         outmsg.append(self.filename + ", ")
-        if type (line) in (ListType, TupleType):
+        if isinstance(line, (list, tuple)):
             outmsg.append("lines %d-%d: " % tuple (line))
         else:
             outmsg.append("line %d: " % line)
         outmsg.append(str(msg))
-        return string.join(outmsg, "")
+        return ''.join(outmsg)
 
 
     def error (self, msg, line=None):
@@ -196,7 +195,7 @@
                 # unescape it (and any other escaped "#"'s that might be
                 # lurking in there) and otherwise leave the line alone.
 
-                pos = string.find (line, "#")
+                pos = line.find("#")
                 if pos == -1:           # no "#" -- no comments
                     pass
 
@@ -219,11 +218,11 @@
                     #   # comment that should be ignored
                     #   there
                     # result in "hello there".
-                    if string.strip(line) == "":
+                    if line.strip() == "":
                         continue
 
                 else:                   # it's an escaped "#"
-                    line = string.replace (line, "\\#", "#")
+                    line = line.replace("\\#", "#")
 
 
             # did previous line end with a backslash? then accumulate
@@ -235,11 +234,11 @@
                     return buildup_line
 
                 if self.collapse_join:
-                    line = string.lstrip (line)
+                    line = line.lstrip()
                 line = buildup_line + line
 
                 # careful: pay attention to line number when incrementing it
-                if type (self.current_line) is ListType:
+                if isinstance(self.current_line, list):
                     self.current_line[1] = self.current_line[1] + 1
                 else:
                     self.current_line = [self.current_line,
@@ -250,7 +249,7 @@
                     return None
 
                 # still have to be careful about incrementing the line number!
-                if type (self.current_line) is ListType:
+                if isinstance(self.current_line, list):
                     self.current_line = self.current_line[1] + 1
                 else:
                     self.current_line = self.current_line + 1
@@ -259,11 +258,11 @@
             # strip whitespace however the client wants (leading and
             # trailing, or one or the other, or neither)
             if self.lstrip_ws and self.rstrip_ws:
-                line = string.strip (line)
+                line = line.strip()
             elif self.lstrip_ws:
-                line = string.lstrip (line)
+                line = line.lstrip()
             elif self.rstrip_ws:
-                line = string.rstrip (line)
+                line = line.rstrip()
 
             # blank line (whether we rstrip'ed or not)? skip to next line
             # if appropriate


More information about the Python-checkins mailing list