Skip to content

Commit a82b4b5

Browse files
author
llllllllll
committed
Makes the old-style class autocomplete work in 2.6 and 3.x
1 parent cb90872 commit a82b4b5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

bpython/autocomplete.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import re
3434
import rlcompleter
3535
import sys
36-
from types import InstanceType, ClassType
3736
from six.moves import range, builtins
3837
from six import string_types, iteritems
3938

@@ -43,6 +42,9 @@
4342
from bpython._py3compat import py3, try_decode
4443
from bpython.lazyre import LazyReCompile
4544

45+
if not py3:
46+
from types import InstanceType, ClassType
47+
4648

4749
# Autocomplete modes
4850
SIMPLE = 'simple'
@@ -540,7 +542,7 @@ def attr_lookup(obj, expr, attr):
540542
words.remove('__abstractmethods__')
541543
except ValueError:
542544
pass
543-
if isinstance(obj, (InstanceType, ClassType)):
545+
if not py3 and isinstance(obj, (InstanceType, ClassType)):
544546
# Account for the __dict__ in an old-style class.
545547
words.append('__dict__')
546548

bpython/test/test_autocomplete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def test_att_matches_found_on_instance(self):
242242
def test_att_matches_found_on_old_style_instance(self):
243243
self.assertSetEqual(self.com.matches(2, 'a.',
244244
locals_={'a': OldStyleFoo()}),
245-
{'a.method', 'a.a', 'a.b'})
245+
set(['a.method', 'a.a', 'a.b']))
246246
self.assertIn(u'a.__dict__',
247247
self.com.matches(3, 'a._', locals_={'a': OldStyleFoo()}))
248248

0 commit comments

Comments
 (0)