Skip to content

Commit bc57c0c

Browse files
committed
Python 3 preparation: use isinstance(x, collections.Callable) instead of callable(x).
Tool-assisted patch.
1 parent 35f006d commit bc57c0c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

roundup/cgi/PageTemplates/Expressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
for Python expressions, string literals, and paths.
2323
"""
2424

25-
import re, sys
25+
import collections, re, sys
2626
from .TALES import Engine, CompilerError, _valid_name, NAME_RE, \
2727
Undefined, Default, _parse_expr
2828

@@ -86,7 +86,7 @@ def render(ob, ns):
8686
ob = call_with_ns(ob.__render_with_namespace__, ns)
8787
else:
8888
base = ob
89-
if callable(base):
89+
if isinstance(base, collections.Callable):
9090
try:
9191
if getattr(base, 'isDocTemp', 0):
9292
ob = call_with_ns(ob, ns, 2)

roundup/instance.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
except ImportError:
3434
import __builtin__ as builtins
3535

36+
import collections
3637
import os
3738
import sys
3839
import warnings
@@ -133,14 +134,14 @@ def open(self, name=None):
133134
if self.optimize:
134135
# execute preloaded schema object
135136
self._exec(self.schema, env)
136-
if callable (self.schema_hook):
137+
if isinstance(self.schema_hook, collections.Callable):
137138
self.schema_hook(**env)
138139
# use preloaded detectors
139140
detectors = self.detectors
140141
else:
141142
# execute the schema file
142143
self._execfile('schema.py', env)
143-
if callable (self.schema_hook):
144+
if isinstance(self.schema_hook, collections.Callable):
144145
self.schema_hook(**env)
145146
# reload extensions and detectors
146147
for extension in self.get_extensions('extensions'):

0 commit comments

Comments
 (0)