Commit b56a8f9e authored by Guido van Rossum's avatar Guido van Rossum

Merged revisions 55795-55816 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/p3yk

........
  r55797 | neal.norwitz | 2007-06-07 00:00:57 -0700 (Thu, 07 Jun 2007) | 3 lines

  Get rid of some remnants of classic classes.  types.ClassType == type.
  Also get rid of almost all uses of the types module and use the builtin name.
........
  r55798 | neal.norwitz | 2007-06-07 00:12:36 -0700 (Thu, 07 Jun 2007) | 1 line

  Remove a use of types, verify commit hook works
........
  r55809 | guido.van.rossum | 2007-06-07 11:11:29 -0700 (Thu, 07 Jun 2007) | 2 lines

  Fix syntax error introduced by Neal in last checkin.
........
parent 846a6d17
...@@ -9,7 +9,6 @@ in the distutils.command package. ...@@ -9,7 +9,6 @@ in the distutils.command package.
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os, re import sys, os, re
from types import *
from distutils.errors import * from distutils.errors import *
from distutils import util, dir_util, file_util, archive_util, dep_util from distutils import util, dir_util, file_util, archive_util, dep_util
from distutils import log from distutils import log
...@@ -245,7 +244,7 @@ class Command: ...@@ -245,7 +244,7 @@ class Command:
elif isinstance(val, basestring): elif isinstance(val, basestring):
setattr(self, option, re.split(r',\s*|\s+', val)) setattr(self, option, re.split(r',\s*|\s+', val))
else: else:
if type(val) is ListType: if isinstance(val, list):
ok = all(isinstance(v, basestring) for v in val) ok = all(isinstance(v, basestring) for v in val)
else: else:
ok = 0 ok = 0
...@@ -422,7 +421,7 @@ class Command: ...@@ -422,7 +421,7 @@ class Command:
# Allow 'infiles' to be a single string # Allow 'infiles' to be a single string
if isinstance(infiles, basestring): if isinstance(infiles, basestring):
infiles = (infiles,) infiles = (infiles,)
elif type(infiles) not in (ListType, TupleType): elif not isinstance(infiles, (list, tuple)):
raise TypeError, \ raise TypeError, \
"'infiles' must be a string, or a list or tuple of strings" "'infiles' must be a string, or a list or tuple of strings"
......
...@@ -9,7 +9,6 @@ being built/installed/distributed. ...@@ -9,7 +9,6 @@ being built/installed/distributed.
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os, re import sys, os, re
from types import *
from copy import copy from copy import copy
try: try:
...@@ -527,7 +526,7 @@ Common commands: (see '--help-commands' for more) ...@@ -527,7 +526,7 @@ Common commands: (see '--help-commands' for more)
# Also make sure that the command object provides a list of its # Also make sure that the command object provides a list of its
# known options. # known options.
if not (hasattr(cmd_class, 'user_options') and if not (hasattr(cmd_class, 'user_options') and
type(cmd_class.user_options) is ListType): isinstance(cmd_class.user_options, list)):
raise DistutilsClassError, \ raise DistutilsClassError, \
("command class %s must provide " + ("command class %s must provide " +
"'user_options' attribute (a list of tuples)") % \ "'user_options' attribute (a list of tuples)") % \
...@@ -543,7 +542,7 @@ Common commands: (see '--help-commands' for more) ...@@ -543,7 +542,7 @@ Common commands: (see '--help-commands' for more)
# Check for help_options in command class. They have a different # Check for help_options in command class. They have a different
# format (tuple of four) so we need to preprocess them here. # format (tuple of four) so we need to preprocess them here.
if (hasattr(cmd_class, 'help_options') and if (hasattr(cmd_class, 'help_options') and
type(cmd_class.help_options) is ListType): isinstance(cmd_class.help_options, list)):
help_options = fix_help_options(cmd_class.help_options) help_options = fix_help_options(cmd_class.help_options)
else: else:
help_options = [] help_options = []
...@@ -561,7 +560,7 @@ Common commands: (see '--help-commands' for more) ...@@ -561,7 +560,7 @@ Common commands: (see '--help-commands' for more)
return return
if (hasattr(cmd_class, 'help_options') and if (hasattr(cmd_class, 'help_options') and
type(cmd_class.help_options) is ListType): isinstance(cmd_class.help_options, list)):
help_option_found=0 help_option_found=0
for (help_option, short, desc, func) in cmd_class.help_options: for (help_option, short, desc, func) in cmd_class.help_options:
if hasattr(opts, parser.get_attr_name(help_option)): if hasattr(opts, parser.get_attr_name(help_option)):
...@@ -646,12 +645,12 @@ Common commands: (see '--help-commands' for more) ...@@ -646,12 +645,12 @@ Common commands: (see '--help-commands' for more)
print() print()
for command in self.commands: for command in self.commands:
if type(command) is ClassType and issubclass(command, Command): if isinstance(command, type) and issubclass(command, Command):
klass = command klass = command
else: else:
klass = self.get_command_class(command) klass = self.get_command_class(command)
if (hasattr(klass, 'help_options') and if (hasattr(klass, 'help_options') and
type(klass.help_options) is ListType): isinstance(klass.help_options, list)):
parser.set_option_table(klass.user_options + parser.set_option_table(klass.user_options +
fix_help_options(klass.help_options)) fix_help_options(klass.help_options))
else: else:
......
...@@ -6,7 +6,6 @@ modules in setup scripts.""" ...@@ -6,7 +6,6 @@ modules in setup scripts."""
__revision__ = "$Id$" __revision__ = "$Id$"
import os, sys import os, sys
from types import *
try: try:
import warnings import warnings
...@@ -104,7 +103,7 @@ class Extension: ...@@ -104,7 +103,7 @@ class Extension:
**kw # To catch unknown keywords **kw # To catch unknown keywords
): ):
assert isinstance(name, basestring), "'name' must be a string" assert isinstance(name, basestring), "'name' must be a string"
assert (type(sources) is ListType and assert (isinstance(sources, list) and
all(isinstance(v, basestring) for v in sources)), \ all(isinstance(v, basestring) for v in sources)), \
"'sources' must be a list of strings" "'sources' must be a list of strings"
......
...@@ -6,7 +6,6 @@ lines, and joining lines with backslashes.""" ...@@ -6,7 +6,6 @@ lines, and joining lines with backslashes."""
__revision__ = "$Id$" __revision__ = "$Id$"
from types import *
import sys, os, io import sys, os, io
...@@ -137,7 +136,7 @@ class TextFile: ...@@ -137,7 +136,7 @@ class TextFile:
if line is None: if line is None:
line = self.current_line line = self.current_line
outmsg.append(self.filename + ", ") outmsg.append(self.filename + ", ")
if type (line) in (ListType, TupleType): if isinstance (line, (list, tuple)):
outmsg.append("lines %d-%d: " % tuple (line)) outmsg.append("lines %d-%d: " % tuple (line))
else: else:
outmsg.append("line %d: " % line) outmsg.append("line %d: " % line)
...@@ -239,7 +238,7 @@ class TextFile: ...@@ -239,7 +238,7 @@ class TextFile:
line = buildup_line + line line = buildup_line + line
# careful: pay attention to line number when incrementing it # 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 self.current_line[1] = self.current_line[1] + 1
else: else:
self.current_line = [self.current_line, self.current_line = [self.current_line,
...@@ -250,7 +249,7 @@ class TextFile: ...@@ -250,7 +249,7 @@ class TextFile:
return None return None
# still have to be careful about incrementing the line number! # 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 self.current_line = self.current_line[1] + 1
else: else:
self.current_line = self.current_line + 1 self.current_line = self.current_line + 1
......
...@@ -16,7 +16,6 @@ the "typical" Unix-style command-line C compiler: ...@@ -16,7 +16,6 @@ the "typical" Unix-style command-line C compiler:
__revision__ = "$Id$" __revision__ = "$Id$"
import os, sys import os, sys
from types import NoneType
from copy import copy from copy import copy
from distutils import sysconfig from distutils import sysconfig
...@@ -212,7 +211,7 @@ class UnixCCompiler(CCompiler): ...@@ -212,7 +211,7 @@ class UnixCCompiler(CCompiler):
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
libraries) libraries)
if not isinstance(output_dir, (basestring, NoneType)): if not isinstance(output_dir, (basestring, type(None))):
raise TypeError, "'output_dir' must be a string or None" raise TypeError, "'output_dir' must be a string or None"
if output_dir is not None: if output_dir is not None:
output_filename = os.path.join(output_dir, output_filename) output_filename = os.path.join(output_dir, output_filename)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment