summaryrefslogtreecommitdiffstats
path: root/Lib/plat-mac
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-06-07 23:15:56 (GMT)
committerGuido van Rossum <guido@python.org>2007-06-07 23:15:56 (GMT)
commit1325790b932c4bab4f8f94f5a36c09f4036ed9f8 (patch)
tree5f4c1d854783a4d082c5867094ec345f4772bf35 /Lib/plat-mac
parent7b955bd125951db694f19a1b8648b806b14bd61f (diff)
downloadcpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.zip
cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.tar.gz
cpython-1325790b932c4bab4f8f94f5a36c09f4036ed9f8.tar.bz2
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. ........
Diffstat (limited to 'Lib/plat-mac')
-rw-r--r--Lib/plat-mac/aepack.py20
-rw-r--r--Lib/plat-mac/aetypes.py11
-rw-r--r--Lib/plat-mac/gensuitemodule.py6
3 files changed, 17 insertions, 20 deletions
diff --git a/Lib/plat-mac/aepack.py b/Lib/plat-mac/aepack.py
index 3511270..7ce8548 100644
--- a/Lib/plat-mac/aepack.py
+++ b/Lib/plat-mac/aepack.py
@@ -13,8 +13,6 @@ coerce(x, wanted_sample) coerces a python object to another python object
#
import struct
-import types
-from types import *
from Carbon import AE
from Carbon.AppleEvents import *
import MacOS
@@ -74,7 +72,7 @@ def pack(x, forcetype = None):
"""Pack a python object into an AE descriptor"""
if forcetype:
- if type(x) is StringType:
+ if isinstance(x, str):
return AE.AECreateDesc(forcetype, x)
else:
return pack(x).AECoerceDesc(forcetype)
@@ -90,29 +88,29 @@ def pack(x, forcetype = None):
return AE.AECreateDesc('fsrf', x.data)
if isinstance(x, AliasType):
return AE.AECreateDesc('alis', x.data)
- if isinstance(x, IntType):
+ if isinstance(x, int):
return AE.AECreateDesc('long', struct.pack('l', x))
- if isinstance(x, FloatType):
+ if isinstance(x, float):
return AE.AECreateDesc('doub', struct.pack('d', x))
- if isinstance(x, StringType):
+ if isinstance(x, str):
return AE.AECreateDesc('TEXT', x)
- if isinstance(x, UnicodeType):
+ if isinstance(x, unicode):
data = x.encode('utf16')
if data[:2] == '\xfe\xff':
data = data[2:]
return AE.AECreateDesc('utxt', data)
- if isinstance(x, ListType):
+ if isinstance(x, list):
list = AE.AECreateList('', 0)
for item in x:
list.AEPutDesc(0, pack(item))
return list
- if isinstance(x, DictionaryType):
+ if isinstance(x, dict):
record = AE.AECreateList('', 1)
for key, value in x.items():
packkey(record, key, value)
#record.AEPutParamDesc(key, pack(value))
return record
- if type(x) == types.ClassType and issubclass(x, ObjectSpecifier):
+ if isinstance(x, type) and issubclass(x, ObjectSpecifier):
# Note: we are getting a class object here, not an instance
return AE.AECreateDesc('type', x.want)
if hasattr(x, '__aepack__'):
@@ -340,7 +338,7 @@ def mkobject(dict):
# to __class__ is safe. Moreover, shouldn't there be a better
# initializer for the classes in the suites?
def mkobjectfrommodule(dict, modulename):
- if type(dict['want']) == types.ClassType and issubclass(dict['want'], ObjectSpecifier):
+ if isinstance(dict['want'], type) and issubclass(dict['want'], ObjectSpecifier):
# The type has already been converted to Python. Convert back:-(
classtype = dict['want']
dict['want'] = aetypes.mktype(classtype.want)
diff --git a/Lib/plat-mac/aetypes.py b/Lib/plat-mac/aetypes.py
index 9b739f6..aacea55 100644
--- a/Lib/plat-mac/aetypes.py
+++ b/Lib/plat-mac/aetypes.py
@@ -2,7 +2,6 @@
from Carbon.AppleEvents import *
import struct
-from types import *
#
# convoluted, since there are cyclic dependencies between this file and
@@ -14,7 +13,7 @@ def pack(*args, **kwargs):
def nice(s):
"""'nice' representation of an object"""
- if type(s) is StringType: return repr(s)
+ if isinstance(s, str): return repr(s)
else: return str(s)
class Unknown:
@@ -222,7 +221,7 @@ class Logical:
return "Logical(%r, %r)" % (self.logc, self.term)
def __str__(self):
- if type(self.term) == ListType and len(self.term) == 2:
+ if isinstance(self.term, list) and len(self.term) == 2:
return "%s %s %s" % (nice(self.term[0]),
self.logc.strip(),
nice(self.term[1]))
@@ -481,13 +480,13 @@ class SelectableItem(ObjectSpecifier):
def __init__(self, want, seld, fr = None):
t = type(seld)
- if t == StringType:
+ if isinstance(t, str):
form = 'name'
elif IsRange(seld):
form = 'rang'
elif IsComparison(seld) or IsLogical(seld):
form = 'test'
- elif t == TupleType:
+ elif isinstance(t, tuple):
# Breakout: specify both form and seld in a tuple
# (if you want ID or rele or somesuch)
form, seld = seld
@@ -513,7 +512,7 @@ class ComponentItem(SelectableItem):
def __str__(self):
seld = self.seld
- if type(seld) == StringType:
+ if isinstance(seld, str):
ss = repr(seld)
elif IsRange(seld):
start, stop = seld.start, seld.stop
diff --git a/Lib/plat-mac/gensuitemodule.py b/Lib/plat-mac/gensuitemodule.py
index 6d1ceae..10a996f 100644
--- a/Lib/plat-mac/gensuitemodule.py
+++ b/Lib/plat-mac/gensuitemodule.py
@@ -279,9 +279,9 @@ def decode(data, verbose=None):
def simplify(item):
"""Recursively replace singleton tuples by their constituent item"""
- if type(item) is types.ListType:
+ if isinstance(item, list):
return map(simplify, item)
- elif type(item) == types.TupleType and len(item) == 2:
+ elif isinstance(item, tuple) and len(item) == 2:
return simplify(item[1])
else:
return item
@@ -352,7 +352,7 @@ def alt_generic(what, f, *args):
def generic(what, f, *args):
if type(what) == types.FunctionType:
return what(f, *args)
- if type(what) == types.ListType:
+ if isinstance(what, list):
record = []
for thing in what:
item = generic(thing[:1], f, *thing[1:])