X Tutup
Skip to content

Commit 4880ebf

Browse files
committed
merge.
2 parents 8129b3a + 21bf1e2 commit 4880ebf

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ v0.9.8
88
dropped and ~/.bpython.ini as config file location is no longer supported.
99
See issue #91.
1010
* Fixed some issues with tuple unpacking in argspec. See issues #133 and #138.
11+
* Fixed a crash with non-ascii filenames in import completion. See issue #139.
1112

1213
v0.9.7.1
1314
--------

bpython/importcompletion.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import os
2626
import sys
2727

28+
py3 = sys.version_info[:2] >= (3, 0)
2829

2930
# The cached list of all known modules
3031
modules = set()
@@ -107,6 +108,10 @@ def find_modules(path):
107108
fo, pathname, _ = imp.find_module(name, [path])
108109
except (ImportError, SyntaxError):
109110
continue
111+
except UnicodeEncodeError:
112+
# Happens with Python 3 when there is a filename in some
113+
# invalid encoding
114+
continue
110115
else:
111116
if fo is not None:
112117
fo.close()
@@ -129,6 +134,12 @@ def find_all_modules(path=None):
129134
if not p:
130135
p = os.curdir
131136
for module in find_modules(p):
137+
if not py3 and not isinstance(module, unicode):
138+
try:
139+
module = module.decode(sys.getfilesystemencoding())
140+
except UnicodeDecodeError:
141+
# Not importable anyway, ignore it
142+
continue
132143
modules.add(module)
133144
yield
134145

bpython/urwid.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,6 @@ def push(self, s, insert_into_history=True):
711711
signal.signal(signal.SIGINT, orig_handler)
712712

713713
def start(self):
714-
# Stolen from bpython.cli again
715-
self.push('from bpython._internal import _help as help\n', False)
716714
self.prompt(False)
717715

718716
def keyboard_interrupt(self):

0 commit comments

Comments
 (0)
X Tutup