File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 29
29
"""
30
30
31
31
import ast
32
- from six import string_types
33
32
import inspect
33
+ from six import string_types
34
34
from six .moves import builtins
35
+ import sys
36
+ import types
35
37
36
38
from bpython import line as line_properties
37
39
from bpython ._py3compat import py3
47
49
_name_type_nodes = (ast .Name ,)
48
50
49
51
52
+ # inspect.isclass is broken in Python 2.6
53
+ if sys .version_info [:2 ] == (2 , 6 ):
54
+ def isclass (obj ):
55
+ return isinstance (obj , (type , types .ClassType ))
56
+ else :
57
+ isclass = inspect .isclass
58
+
59
+
50
60
class EvaluationError (Exception ):
51
61
"""Raised if an exception occurred in safe_eval."""
52
62
@@ -267,7 +277,7 @@ def safe_get_attribute_new_style(obj, attr):
267
277
if not is_new_style (obj ):
268
278
raise ValueError ("%r is not a new-style class or object" % obj )
269
279
to_look_through = (obj .__mro__
270
- if inspect . isclass (obj )
280
+ if isclass (obj )
271
281
else (obj ,) + type (obj ).__mro__ )
272
282
273
283
for cls in to_look_through :
You can’t perform that action at this time.
0 commit comments