Skip to content

Commit e3e9061

Browse files
sebastinasthomasballinger
authored andcommitted
Remove workarounds for no longer supported Python versions
collections.Callable was used for Python 3.0 - 3.1 since callable was missing in these versions. Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent b0d9ae4 commit e3e9061

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

bpython/inspection.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,20 @@
2525
#
2626

2727
from __future__ import with_statement
28-
import collections
2928
import inspect
3029
import io
3130
import keyword
3231
import pydoc
33-
import types
3432
from six.moves import range
3533

3634
from pygments.token import Token
3735

3836
from bpython._py3compat import PythonLexer, py3
3937
from bpython.lazyre import LazyReCompile
4038

41-
try:
42-
collections.Callable
43-
has_collections_callable = True
44-
except AttributeError:
45-
has_collections_callable = False
46-
try:
47-
types.InstanceType
48-
has_instance_type = True
49-
except AttributeError:
50-
has_instance_type = False
51-
5239
if not py3:
40+
import types
41+
5342
_name = LazyReCompile(r'[a-zA-Z_]\w*$')
5443

5544

@@ -272,13 +261,7 @@ def is_eval_safe_name(string):
272261

273262

274263
def is_callable(obj):
275-
if has_instance_type and isinstance(obj, types.InstanceType):
276-
# Work around a CPython bug, see CPython issue #7624
277-
return callable(obj)
278-
elif has_collections_callable:
279-
return isinstance(obj, collections.Callable)
280-
else:
281-
return callable(obj)
264+
return callable(obj)
282265

283266

284267
get_encoding_re = LazyReCompile(r'coding[:=]\s*([-\w.]+)')

0 commit comments

Comments
 (0)