Skip to content

Commit

Permalink
Merged revisions 55795-55816 via svnmerge from
Browse files Browse the repository at this point in the history
svn+ssh://[email protected]/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.
........
  • Loading branch information
gvanrossum committed Jun 7, 2007
1 parent 7b955bd commit 1325790
Show file tree
Hide file tree
Showing 40 changed files with 161 additions and 202 deletions.
7 changes: 3 additions & 4 deletions Lib/bsddb/dbtables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import copy
import xdrlib
import random
from types import ListType, StringType
import cPickle as pickle

try:
Expand Down Expand Up @@ -229,7 +228,7 @@ def CreateTable(self, table, columns):
raises TableDBError if it already exists or for other DB errors.
"""
assert isinstance(columns, ListType)
assert isinstance(columns, list)
txn = None
try:
# checking sanity of the table and column names here on
Expand Down Expand Up @@ -270,7 +269,7 @@ def ListTableColumns(self, table):
"""Return a list of columns in the given table.
[] if the table doesn't exist.
"""
assert isinstance(table, StringType)
assert isinstance(table, str)
if contains_metastrings(table):
raise ValueError, "bad table name: contains reserved metastrings"

Expand Down Expand Up @@ -300,7 +299,7 @@ def CreateOrExtendTable(self, table, columns):
additional columns present in the given list as well as
all of its current columns.
"""
assert isinstance(columns, ListType)
assert isinstance(columns, list)
try:
self.CreateTable(table, columns)
except TableAlreadyExists:
Expand Down
8 changes: 4 additions & 4 deletions Lib/cgitb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def scanvars(reader, frame, locals):

def html(einfo, context=5):
"""Return a nice HTML document describing a given traceback."""
import os, types, time, traceback, linecache, inspect, pydoc
import os, time, traceback, linecache, inspect, pydoc

etype, evalue, etb = einfo
if type(etype) is types.ClassType:
if isinstance(etype, type):
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
Expand Down Expand Up @@ -188,10 +188,10 @@ def reader(lnum=[lnum]):

def text(einfo, context=5):
"""Return a plain text document describing a given traceback."""
import os, types, time, traceback, linecache, inspect, pydoc
import os, time, traceback, linecache, inspect, pydoc

etype, evalue, etb = einfo
if type(etype) is types.ClassType:
if isinstance(etype, type):
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
Expand Down
10 changes: 6 additions & 4 deletions Lib/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ def copy(x):
def _copy_immutable(x):
return x
for t in (type(None), int, float, bool, str, tuple,
frozenset, type, range, types.ClassType,
frozenset, type, range,
types.BuiltinFunctionType,
types.FunctionType):
d[t] = _copy_immutable
for name in ("ComplexType", "UnicodeType", "CodeType"):
t = getattr(types, name, None)
t = getattr(types, "CodeType", None)
if t is not None:
d[t] = _copy_immutable
for name in ("complex", "unicode"):
t = globals()['__builtins__'].get(name)
if t is not None:
d[t] = _copy_immutable

Expand Down Expand Up @@ -192,7 +195,6 @@ def _deepcopy_atomic(x, memo):
pass
d[type] = _deepcopy_atomic
d[range] = _deepcopy_atomic
d[types.ClassType] = _deepcopy_atomic
d[types.BuiltinFunctionType] = _deepcopy_atomic
d[types.FunctionType] = _deepcopy_atomic

Expand Down
2 changes: 1 addition & 1 deletion Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def dis(x=None):
items = sorted(x.__dict__.items())
for name, x1 in items:
if isinstance(x1, (types.MethodType, types.FunctionType,
types.CodeType, types.ClassType, type)):
types.CodeType, type)):
print("Disassembly of %s:" % name)
try:
dis(x1)
Expand Down
5 changes: 2 additions & 3 deletions Lib/distutils/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
__revision__ = "$Id$"

import sys, os, re
from types import *
from distutils.errors import *
from distutils import util, dir_util, file_util, archive_util, dep_util
from distutils import log
Expand Down Expand Up @@ -245,7 +244,7 @@ def ensure_string_list (self, option):
elif isinstance(val, basestring):
setattr(self, option, re.split(r',\s*|\s+', val))
else:
if type(val) is ListType:
if isinstance(val, list):
ok = all(isinstance(v, basestring) for v in val)
else:
ok = 0
Expand Down Expand Up @@ -422,7 +421,7 @@ def make_file (self, infiles, outfile, func, args,
# Allow 'infiles' to be a single string
if isinstance(infiles, basestring):
infiles = (infiles,)
elif type(infiles) not in (ListType, TupleType):
elif not isinstance(infiles, (list, tuple)):
raise TypeError, \
"'infiles' must be a string, or a list or tuple of strings"

Expand Down
11 changes: 5 additions & 6 deletions Lib/distutils/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
__revision__ = "$Id$"

import sys, os, re
from types import *
from copy import copy

try:
Expand Down Expand Up @@ -527,7 +526,7 @@ def _parse_command_opts (self, parser, args):
# Also make sure that the command object provides a list of its
# known options.
if not (hasattr(cmd_class, 'user_options') and
type(cmd_class.user_options) is ListType):
isinstance(cmd_class.user_options, list)):
raise DistutilsClassError, \
("command class %s must provide " +
"'user_options' attribute (a list of tuples)") % \
Expand All @@ -543,7 +542,7 @@ def _parse_command_opts (self, parser, args):
# Check for help_options in command class. They have a different
# format (tuple of four) so we need to preprocess them here.
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)
else:
help_options = []
Expand All @@ -561,7 +560,7 @@ def _parse_command_opts (self, parser, args):
return

if (hasattr(cmd_class, 'help_options') and
type(cmd_class.help_options) is ListType):
isinstance(cmd_class.help_options, list)):
help_option_found=0
for (help_option, short, desc, func) in cmd_class.help_options:
if hasattr(opts, parser.get_attr_name(help_option)):
Expand Down Expand Up @@ -646,12 +645,12 @@ def _show_help (self,
print()

for command in self.commands:
if type(command) is ClassType and issubclass(command, Command):
if isinstance(command, type) and issubclass(command, Command):
klass = command
else:
klass = self.get_command_class(command)
if (hasattr(klass, 'help_options') and
type(klass.help_options) is ListType):
isinstance(klass.help_options, list)):
parser.set_option_table(klass.user_options +
fix_help_options(klass.help_options))
else:
Expand Down
3 changes: 1 addition & 2 deletions Lib/distutils/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
__revision__ = "$Id$"

import os, sys
from types import *

try:
import warnings
Expand Down Expand Up @@ -104,7 +103,7 @@ def __init__ (self, name, sources,
**kw # To catch unknown keywords
):
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)), \
"'sources' must be a list of strings"

Expand Down
7 changes: 3 additions & 4 deletions Lib/distutils/text_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

__revision__ = "$Id$"

from types import *
import sys, os, io


Expand Down Expand Up @@ -137,7 +136,7 @@ def gen_error (self, msg, line=None):
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)
Expand Down Expand Up @@ -239,7 +238,7 @@ def readline (self):
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,
Expand All @@ -250,7 +249,7 @@ def readline (self):
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
Expand Down
3 changes: 1 addition & 2 deletions Lib/distutils/unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
__revision__ = "$Id$"

import os, sys
from types import NoneType
from copy import copy

from distutils import sysconfig
Expand Down Expand Up @@ -212,7 +211,7 @@ def link(self, target_desc, objects,

lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
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"
if output_dir is not None:
output_filename = os.path.join(output_dir, output_filename)
Expand Down
6 changes: 3 additions & 3 deletions Lib/idlelib/CallTips.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,22 @@ def get_arg_text(ob):
arg_text = ""
if ob is not None:
arg_offset = 0
if type(ob) in (types.ClassType, types.TypeType):
if isinstance(ob, type):
# Look for the highest __init__ in the class chain.
fob = _find_constructor(ob)
if fob is None:
fob = lambda: None
else:
arg_offset = 1
elif type(ob)==types.MethodType:
elif isinstace(ob, types.MethodType):
# bit of a hack for methods - turn it into a function
# but we drop the "self" param.
fob = ob.im_func
arg_offset = 1
else:
fob = ob
# Try to build one for Python defined functions
if type(fob) in [types.FunctionType, types.LambdaType]:
if isinstance(fob, (types.FunctionType, types.LambdaType)):
argcount = fob.__code__.co_argcount
real_args = fob.__code__.co_varnames[arg_offset:argcount]
defaults = fob.__defaults__ or []
Expand Down
17 changes: 7 additions & 10 deletions Lib/idlelib/ObjectBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,14 @@ def keys(self):
pass
return keys

from types import *

dispatch = {
IntType: AtomicObjectTreeItem,
LongType: AtomicObjectTreeItem,
FloatType: AtomicObjectTreeItem,
StringType: AtomicObjectTreeItem,
TupleType: SequenceTreeItem,
ListType: SequenceTreeItem,
DictType: DictTreeItem,
ClassType: ClassTreeItem,
int: AtomicObjectTreeItem,
float: AtomicObjectTreeItem,
str: AtomicObjectTreeItem,
tuple: SequenceTreeItem,
list: SequenceTreeItem,
dict: DictTreeItem,
type: ClassTreeItem,
}

def make_objecttreeitem(labeltext, object, setfunction=None):
Expand Down
4 changes: 2 additions & 2 deletions Lib/idlelib/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def getresponse(self, myseq, wait):
def _proxify(self, obj):
if isinstance(obj, RemoteProxy):
return RPCProxy(self, obj.oid)
if isinstance(obj, types.ListType):
if isinstance(obj, list):
return map(self._proxify, obj)
# XXX Check for other types -- not currently needed
return obj
Expand Down Expand Up @@ -574,7 +574,7 @@ def _getmethods(obj, methods):
attr = getattr(obj, name)
if hasattr(attr, '__call__'):
methods[name] = 1
if type(obj) == types.ClassType:
if isinstance(obj, type):
for super in obj.__bases__:
_getmethods(super, methods)

Expand Down
2 changes: 1 addition & 1 deletion Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def isclass(object):
Class objects provide these attributes:
__doc__ documentation string
__module__ name of module in which this class was defined"""
return isinstance(object, types.ClassType) or hasattr(object, '__bases__')
return isinstance(object, type) or hasattr(object, '__bases__')

def ismethod(object):
"""Return true if the object is an instance method.
Expand Down
2 changes: 1 addition & 1 deletion Lib/lib-tk/ScrolledText.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, master=None, cnf=None, **kw):
cnf = _cnfmerge((cnf, kw))
fcnf = {}
for k in cnf.keys():
if type(k) == ClassType or k == 'name':
if isinstace(k, type) or k == 'name':
fcnf[k] = cnf[k]
del cnf[k]
self.frame = Frame(master, **fcnf)
Expand Down
Loading

0 comments on commit 1325790

Please sign in to comment.