Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1325790

Browse files
committed
Merged revisions 55795-55816 via svnmerge from
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. ........
1 parent 7b955bd commit 1325790

40 files changed

Lines changed: 161 additions & 202 deletions

Lib/bsddb/dbtables.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import copy
2323
import xdrlib
2424
import random
25-
from types import ListType, StringType
2625
import cPickle as pickle
2726

2827
try:
@@ -229,7 +228,7 @@ def CreateTable(self, table, columns):
229228
230229
raises TableDBError if it already exists or for other DB errors.
231230
"""
232-
assert isinstance(columns, ListType)
231+
assert isinstance(columns, list)
233232
txn = None
234233
try:
235234
# checking sanity of the table and column names here on
@@ -270,7 +269,7 @@ def ListTableColumns(self, table):
270269
"""Return a list of columns in the given table.
271270
[] if the table doesn't exist.
272271
"""
273-
assert isinstance(table, StringType)
272+
assert isinstance(table, str)
274273
if contains_metastrings(table):
275274
raise ValueError, "bad table name: contains reserved metastrings"
276275

@@ -300,7 +299,7 @@ def CreateOrExtendTable(self, table, columns):
300299
additional columns present in the given list as well as
301300
all of its current columns.
302301
"""
303-
assert isinstance(columns, ListType)
302+
assert isinstance(columns, list)
304303
try:
305304
self.CreateTable(table, columns)
306305
except TableAlreadyExists:

Lib/cgitb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ def scanvars(reader, frame, locals):
9696

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

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

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

193193
etype, evalue, etb = einfo
194-
if type(etype) is types.ClassType:
194+
if isinstance(etype, type):
195195
etype = etype.__name__
196196
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
197197
date = time.ctime(time.time())

Lib/copy.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ def copy(x):
100100
def _copy_immutable(x):
101101
return x
102102
for t in (type(None), int, float, bool, str, tuple,
103-
frozenset, type, range, types.ClassType,
103+
frozenset, type, range,
104104
types.BuiltinFunctionType,
105105
types.FunctionType):
106106
d[t] = _copy_immutable
107-
for name in ("ComplexType", "UnicodeType", "CodeType"):
108-
t = getattr(types, name, None)
107+
t = getattr(types, "CodeType", None)
108+
if t is not None:
109+
d[t] = _copy_immutable
110+
for name in ("complex", "unicode"):
111+
t = globals()['__builtins__'].get(name)
109112
if t is not None:
110113
d[t] = _copy_immutable
111114

@@ -192,7 +195,6 @@ def _deepcopy_atomic(x, memo):
192195
pass
193196
d[type] = _deepcopy_atomic
194197
d[range] = _deepcopy_atomic
195-
d[types.ClassType] = _deepcopy_atomic
196198
d[types.BuiltinFunctionType] = _deepcopy_atomic
197199
d[types.FunctionType] = _deepcopy_atomic
198200

Lib/dis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def dis(x=None):
2626
items = sorted(x.__dict__.items())
2727
for name, x1 in items:
2828
if isinstance(x1, (types.MethodType, types.FunctionType,
29-
types.CodeType, types.ClassType, type)):
29+
types.CodeType, type)):
3030
print("Disassembly of %s:" % name)
3131
try:
3232
dis(x1)

Lib/distutils/cmd.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
__revision__ = "$Id$"
1010

1111
import sys, os, re
12-
from types import *
1312
from distutils.errors import *
1413
from distutils import util, dir_util, file_util, archive_util, dep_util
1514
from distutils import log
@@ -245,7 +244,7 @@ def ensure_string_list (self, option):
245244
elif isinstance(val, basestring):
246245
setattr(self, option, re.split(r',\s*|\s+', val))
247246
else:
248-
if type(val) is ListType:
247+
if isinstance(val, list):
249248
ok = all(isinstance(v, basestring) for v in val)
250249
else:
251250
ok = 0
@@ -422,7 +421,7 @@ def make_file (self, infiles, outfile, func, args,
422421
# Allow 'infiles' to be a single string
423422
if isinstance(infiles, basestring):
424423
infiles = (infiles,)
425-
elif type(infiles) not in (ListType, TupleType):
424+
elif not isinstance(infiles, (list, tuple)):
426425
raise TypeError, \
427426
"'infiles' must be a string, or a list or tuple of strings"
428427

Lib/distutils/dist.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
__revision__ = "$Id$"
1010

1111
import sys, os, re
12-
from types import *
1312
from copy import copy
1413

1514
try:
@@ -527,7 +526,7 @@ def _parse_command_opts (self, parser, args):
527526
# Also make sure that the command object provides a list of its
528527
# known options.
529528
if not (hasattr(cmd_class, 'user_options') and
530-
type(cmd_class.user_options) is ListType):
529+
isinstance(cmd_class.user_options, list)):
531530
raise DistutilsClassError, \
532531
("command class %s must provide " +
533532
"'user_options' attribute (a list of tuples)") % \
@@ -543,7 +542,7 @@ def _parse_command_opts (self, parser, args):
543542
# Check for help_options in command class. They have a different
544543
# format (tuple of four) so we need to preprocess them here.
545544
if (hasattr(cmd_class, 'help_options') and
546-
type(cmd_class.help_options) is ListType):
545+
isinstance(cmd_class.help_options, list)):
547546
help_options = fix_help_options(cmd_class.help_options)
548547
else:
549548
help_options = []
@@ -561,7 +560,7 @@ def _parse_command_opts (self, parser, args):
561560
return
562561

563562
if (hasattr(cmd_class, 'help_options') and
564-
type(cmd_class.help_options) is ListType):
563+
isinstance(cmd_class.help_options, list)):
565564
help_option_found=0
566565
for (help_option, short, desc, func) in cmd_class.help_options:
567566
if hasattr(opts, parser.get_attr_name(help_option)):
@@ -646,12 +645,12 @@ def _show_help (self,
646645
print()
647646

648647
for command in self.commands:
649-
if type(command) is ClassType and issubclass(command, Command):
648+
if isinstance(command, type) and issubclass(command, Command):
650649
klass = command
651650
else:
652651
klass = self.get_command_class(command)
653652
if (hasattr(klass, 'help_options') and
654-
type(klass.help_options) is ListType):
653+
isinstance(klass.help_options, list)):
655654
parser.set_option_table(klass.user_options +
656655
fix_help_options(klass.help_options))
657656
else:

Lib/distutils/extension.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
__revision__ = "$Id$"
77

88
import os, sys
9-
from types import *
109

1110
try:
1211
import warnings
@@ -104,7 +103,7 @@ def __init__ (self, name, sources,
104103
**kw # To catch unknown keywords
105104
):
106105
assert isinstance(name, basestring), "'name' must be a string"
107-
assert (type(sources) is ListType and
106+
assert (isinstance(sources, list) and
108107
all(isinstance(v, basestring) for v in sources)), \
109108
"'sources' must be a list of strings"
110109

Lib/distutils/text_file.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
__revision__ = "$Id$"
88

9-
from types import *
109
import sys, os, io
1110

1211

@@ -137,7 +136,7 @@ def gen_error (self, msg, line=None):
137136
if line is None:
138137
line = self.current_line
139138
outmsg.append(self.filename + ", ")
140-
if type (line) in (ListType, TupleType):
139+
if isinstance (line, (list, tuple)):
141140
outmsg.append("lines %d-%d: " % tuple (line))
142141
else:
143142
outmsg.append("line %d: " % line)
@@ -239,7 +238,7 @@ def readline (self):
239238
line = buildup_line + line
240239

241240
# careful: pay attention to line number when incrementing it
242-
if type (self.current_line) is ListType:
241+
if isinstance (self.current_line, list):
243242
self.current_line[1] = self.current_line[1] + 1
244243
else:
245244
self.current_line = [self.current_line,
@@ -250,7 +249,7 @@ def readline (self):
250249
return None
251250

252251
# still have to be careful about incrementing the line number!
253-
if type (self.current_line) is ListType:
252+
if isinstance (self.current_line, list):
254253
self.current_line = self.current_line[1] + 1
255254
else:
256255
self.current_line = self.current_line + 1

Lib/distutils/unixccompiler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
__revision__ = "$Id$"
1717

1818
import os, sys
19-
from types import NoneType
2019
from copy import copy
2120

2221
from distutils import sysconfig
@@ -212,7 +211,7 @@ def link(self, target_desc, objects,
212211

213212
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
214213
libraries)
215-
if not isinstance(output_dir, (basestring, NoneType)):
214+
if not isinstance(output_dir, (basestring, type(None))):
216215
raise TypeError, "'output_dir' must be a string or None"
217216
if output_dir is not None:
218217
output_filename = os.path.join(output_dir, output_filename)

Lib/idlelib/CallTips.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,22 @@ def get_arg_text(ob):
131131
arg_text = ""
132132
if ob is not None:
133133
arg_offset = 0
134-
if type(ob) in (types.ClassType, types.TypeType):
134+
if isinstance(ob, type):
135135
# Look for the highest __init__ in the class chain.
136136
fob = _find_constructor(ob)
137137
if fob is None:
138138
fob = lambda: None
139139
else:
140140
arg_offset = 1
141-
elif type(ob)==types.MethodType:
141+
elif isinstace(ob, types.MethodType):
142142
# bit of a hack for methods - turn it into a function
143143
# but we drop the "self" param.
144144
fob = ob.im_func
145145
arg_offset = 1
146146
else:
147147
fob = ob
148148
# Try to build one for Python defined functions
149-
if type(fob) in [types.FunctionType, types.LambdaType]:
149+
if isinstance(fob, (types.FunctionType, types.LambdaType)):
150150
argcount = fob.__code__.co_argcount
151151
real_args = fob.__code__.co_varnames[arg_offset:argcount]
152152
defaults = fob.__defaults__ or []

0 commit comments

Comments
 (0)