summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-10-09 22:05:45 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-10-09 22:05:45 (GMT)
commitde0559998fef231efc9ecbdef5b3a195d4eaa28d (patch)
tree235b05866ae52f80d81f2953c663d74f1de6dae1 /Lib
parent0c8bee639368324b750176ee171cadd33847f18e (diff)
downloadcpython-de0559998fef231efc9ecbdef5b3a195d4eaa28d.zip
cpython-de0559998fef231efc9ecbdef5b3a195d4eaa28d.tar.gz
cpython-de0559998fef231efc9ecbdef5b3a195d4eaa28d.tar.bz2
replace callable()
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/dist.py2
-rw-r--r--Lib/encodings/__init__.py12
-rw-r--r--Lib/idlelib/rpc.py4
-rw-r--r--Lib/imputil.py4
-rwxr-xr-xLib/lib-tk/Tix.py2
-rw-r--r--Lib/lib-tk/Tkinter.py6
-rw-r--r--Lib/timeit.py6
7 files changed, 18 insertions, 18 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index f49afcc..eb7d01c 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -545,7 +545,7 @@ Common commands: (see '--help-commands' for more)
for (help_option, short, desc, func) in cmd_class.help_options:
if hasattr(opts, parser.get_attr_name(help_option)):
help_option_found=1
- if callable(func):
+ if hasattr(func, '__call__'):
func()
else:
raise DistutilsClassError(
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index aea7c5e..7945530 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -123,12 +123,12 @@ def search_function(encoding):
raise CodecRegistryError,\
'module "%s" (%s) failed to register' % \
(mod.__name__, mod.__file__)
- if not callable(entry[0]) or \
- not callable(entry[1]) or \
- (entry[2] is not None and not callable(entry[2])) or \
- (entry[3] is not None and not callable(entry[3])) or \
- (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \
- (len(entry) > 5 and entry[5] is not None and not callable(entry[5])):
+ if not hasattr(entry[0], '__call__') or \
+ not hasattr(entry[1], '__call__') or \
+ (entry[2] is not None and not hasattr(entry[2], '__call__')) or \
+ (entry[3] is not None and not hasattr(entry[3], '__call__')) or \
+ (len(entry) > 4 and entry[4] is not None and not hasattr(entry[4], '__call__')) or \
+ (len(entry) > 5 and entry[5] is not None and not hasattr(entry[5], '__call__')):
raise CodecRegistryError,\
'incompatible codecs in module "%s" (%s)' % \
(mod.__name__, mod.__file__)
diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py
index d492984..b3b786d 100644
--- a/Lib/idlelib/rpc.py
+++ b/Lib/idlelib/rpc.py
@@ -570,7 +570,7 @@ def _getmethods(obj, methods):
# Adds names to dictionary argument 'methods'
for name in dir(obj):
attr = getattr(obj, name)
- if callable(attr):
+ if hasattr(attr, '__call__'):
methods[name] = 1
if type(obj) == types.InstanceType:
_getmethods(obj.__class__, methods)
@@ -581,7 +581,7 @@ def _getmethods(obj, methods):
def _getattributes(obj, attributes):
for name in dir(obj):
attr = getattr(obj, name)
- if not callable(attr):
+ if not hasattr(attr, '__call__'):
attributes[name] = 1
class MethodProxy(object):
diff --git a/Lib/imputil.py b/Lib/imputil.py
index 8b37ef4..a907287 100644
--- a/Lib/imputil.py
+++ b/Lib/imputil.py
@@ -51,7 +51,7 @@ class ImportManager:
self.namespace['__import__'] = self.previous_importer
def add_suffix(self, suffix, importFunc):
- assert callable(importFunc)
+ assert hasattr(importFunc, '__call__')
self.fs_imp.add_suffix(suffix, importFunc)
######################################################################
@@ -539,7 +539,7 @@ class _FilesystemImporter(Importer):
self.suffixes = [ ]
def add_suffix(self, suffix, importFunc):
- assert callable(importFunc)
+ assert hasattr(importFunc, '__call__')
self.suffixes.append((suffix, importFunc))
def import_from_dir(self, dir, fqname):
diff --git a/Lib/lib-tk/Tix.py b/Lib/lib-tk/Tix.py
index 2616252..f1a1091 100755
--- a/Lib/lib-tk/Tix.py
+++ b/Lib/lib-tk/Tix.py
@@ -405,7 +405,7 @@ class TixWidget(Tkinter.Widget):
elif kw: cnf = kw
options = ()
for k, v in cnf.items():
- if callable(v):
+ if hasattr(v, '__call__'):
v = self._register(v)
options = options + ('-'+k, v)
return master.tk.call(('image', 'create', imgtype,) + options)
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 46b2781..4dcb256 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -1047,7 +1047,7 @@ class Misc:
for k, v in cnf.items():
if v is not None:
if k[-1] == '_': k = k[:-1]
- if callable(v):
+ if hasattr(v, '__call__'):
v = self._register(v)
elif isinstance(v, (tuple, list)):
nv = []
@@ -3194,7 +3194,7 @@ class Image:
elif kw: cnf = kw
options = ()
for k, v in cnf.items():
- if callable(v):
+ if hasattr(v, '__call__'):
v = self._register(v)
options = options + ('-'+k, v)
self.tk.call(('image', 'create', imgtype, name,) + options)
@@ -3217,7 +3217,7 @@ class Image:
for k, v in _cnfmerge(kw).items():
if v is not None:
if k[-1] == '_': k = k[:-1]
- if callable(v):
+ if hasattr(v, '__call__'):
v = self._register(v)
res = res + ('-'+k, v)
self.tk.call((self.name, 'config') + res)
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 9054243..052f140 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -126,7 +126,7 @@ class Timer:
if isinstance(setup, basestring):
setup = reindent(setup, 4)
src = template % {'stmt': stmt, 'setup': setup}
- elif callable(setup):
+ elif hasattr(setup, '__call__'):
src = template % {'stmt': stmt, 'setup': '_setup()'}
ns['_setup'] = setup
else:
@@ -135,13 +135,13 @@ class Timer:
code = compile(src, dummy_src_name, "exec")
exec code in globals(), ns
self.inner = ns["inner"]
- elif callable(stmt):
+ elif hasattr(stmt, '__call__'):
self.src = None
if isinstance(setup, basestring):
_setup = setup
def setup():
exec _setup in globals(), ns
- elif not callable(setup):
+ elif not hasattr(setup, '__call__'):
raise ValueError("setup is neither a string nor callable")
self.inner = _template_func(setup, stmt)
else: