diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-25 03:17:59 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-11-25 03:17:59 (GMT) |
commit | d752f7d8e851eb6160bbb1bb0e506652ec037f10 (patch) | |
tree | a31a2bd153f529be28c4172602d6f5abebf76f31 /Lib | |
parent | f9232678aede501ea6cde3bbbcb08de068c16153 (diff) | |
download | cpython-d752f7d8e851eb6160bbb1bb0e506652ec037f10.zip cpython-d752f7d8e851eb6160bbb1bb0e506652ec037f10.tar.gz cpython-d752f7d8e851eb6160bbb1bb0e506652ec037f10.tar.bz2 |
No need for types, use isinstance
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/compiler/misc.py | 3 | ||||
-rw-r--r-- | Lib/compiler/pyassem.py | 3 | ||||
-rw-r--r-- | Lib/compiler/pycodegen.py | 9 |
3 files changed, 6 insertions, 9 deletions
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py index 6d5eaa8..8d91770 100644 --- a/Lib/compiler/misc.py +++ b/Lib/compiler/misc.py @@ -1,9 +1,8 @@ -import types def flatten(tup): elts = [] for elt in tup: - if type(elt) == types.TupleType: + if isinstance(elt, tuple): elts = elts + flatten(elt) else: elts.append(elt) diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py index e1fb063..7b6cee6 100644 --- a/Lib/compiler/pyassem.py +++ b/Lib/compiler/pyassem.py @@ -3,7 +3,6 @@ import dis import new import sys -import types from compiler import misc from compiler.consts \ @@ -641,7 +640,7 @@ def getArgCount(args): def twobyte(val): """Convert an int argument into high and low bytes""" - assert type(val) == types.IntType + assert isinstance(val, int) return divmod(val, 256) class LineAddrTable: diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index 87558b2..4866e0e 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -3,7 +3,6 @@ import os import marshal import struct import sys -import types from cStringIO import StringIO from compiler import ast, parse, walk, syntax @@ -1312,7 +1311,7 @@ class AbstractFunctionCode: def generateArgUnpack(self, args): for i in range(len(args)): arg = args[i] - if type(arg) == types.TupleType: + if isinstance(arg, tuple): self.emit('LOAD_FAST', '.%d' % (i * 2)) self.unpackSequence(arg) @@ -1322,7 +1321,7 @@ class AbstractFunctionCode: else: self.emit('UNPACK_TUPLE', len(tup)) for elt in tup: - if type(elt) == types.TupleType: + if isinstance(elt, tuple): self.unpackSequence(elt) else: self._nameOp('STORE', elt) @@ -1408,9 +1407,9 @@ def generateArgList(arglist): count = 0 for i in range(len(arglist)): elt = arglist[i] - if type(elt) == types.StringType: + if isinstance(elt, str): args.append(elt) - elif type(elt) == types.TupleType: + elif isinstance(elt, tuple): args.append(TupleArg(i * 2, elt)) extra.extend(misc.flatten(elt)) count = count + 1 |