Visitar URL original
merge · pythonthings/bpython@d4b8128 · GitHub
Skip to content

Commit d4b8128

Browse files
committed
merge
2 parents bc588d4 + 7bb3b4a commit d4b8128

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎bpython/cli.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ def log(x):
6969
f.write('%s\n' % (x,))
7070

7171
py3 = sys.version_info[0] == 3
72+
if not py3:
73+
import inspect
74+
7275
stdscr = None
7376

7477
def getpreferredencoding():
@@ -676,7 +679,13 @@ def mkargspec(self, topline, down):
676679
if k == in_arg or i == in_arg:
677680
color |= curses.A_BOLD
678681

679-
self.list_win.addstr(str(i), color)
682+
if not py3:
683+
# See issue #138: We need to format tuple unpacking correctly
684+
# We use the undocumented function inspection.strseq() for
685+
# that. Fortunately, that madness is gone in Python 3.
686+
self.list_win.addstr(inspect.strseq(i, str), color)
687+
else:
688+
self.list_win.addstr(str(i), color)
680689
if kw:
681690
self.list_win.addstr('=', punctuation_colpair)
682691
self.list_win.addstr(kw, get_colpair(self.config, 'token'))

‎bpython/repl.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def complete(self, tab=False):
588588

589589
if not e and self.argspec:
590590
matches.extend(name + '=' for name in self.argspec[1][0]
591-
if name.startswith(cw))
591+
if isinstance(name, basestring) and name.startswith(cw))
592592
if py3:
593593
matches.extend(name + '=' for name in self.argspec[1][4]
594594
if name.startswith(cw))

‎bpython/urwid.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import urwid
5353

5454
py3 = sys.version_info[0] == 3
55+
if not py3:
56+
import inspect
5557

5658
Parenthesis = Token.Punctuation.Parenthesis
5759

@@ -541,7 +543,13 @@ def _populate_completion(self):
541543
if k == in_arg or i == in_arg:
542544
color = 'bold ' + color
543545

544-
markup.append((color, str(i)))
546+
if not py3:
547+
# See issue #138: We need to format tuple unpacking correctly
548+
# We use the undocumented function inspection.strseq() for
549+
# that. Fortunately, that madness is gone in Python 3.
550+
markup.append((color, inspect.strseq(i, str)))
551+
else:
552+
markup.append((color, str(i)))
545553
if kw:
546554
markup.extend([('punctuation', '='),
547555
('token', kw)])

0 commit comments

Comments
 (0)