Skip to content

Commit 331c9fd

Browse files
committed
Python 3 compatible __builtin__ import
1 parent 7e0653b commit 331c9fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bpython/autocomplete.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# THE SOFTWARE.
2222
#
2323

24-
import __builtin__
2524
import __main__
2625
import abc
2726
import keyword
@@ -36,6 +35,11 @@
3635
from bpython._py3compat import py3
3736
from bpython.lazyre import LazyReCompile
3837

38+
try:
39+
import builtins
40+
except ImportError:
41+
import __builtin__ as builtins
42+
3943

4044
# Autocomplete modes
4145
SIMPLE = 'simple'
@@ -286,7 +290,7 @@ def matches(self, cursor_offset, line, **kwargs):
286290
for word in keyword.kwlist:
287291
if method_match(word, n, text):
288292
matches.add(word)
289-
for nspace in [__builtin__.__dict__, locals_]:
293+
for nspace in [builtins.__dict__, locals_]:
290294
for word, val in nspace.items():
291295
if method_match(word, len(text), text) and word != "__builtins__":
292296
matches.add(_callable_postfix(val, word))

0 commit comments

Comments
 (0)