Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
stop str-ing in Interp.write, send FmtStr to stderr instead
  • Loading branch information
mlauter committed Sep 4, 2014
commit b40ce7d5563ca867e7d13cf358c0b2cc3f516259
6 changes: 4 additions & 2 deletions bpython/curtsiesfrontend/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BPythonFormatter(Formatter):
Pygments highlight() method and slops
them into the appropriate format string
as defined above, then writes to the outfile
object the final formatted string.
object the final formatted string. This does not write real strings. It writes format string (FmtStr) objects.

See the Pygments source for more info; it's pretty
straightforward."""
Expand All @@ -54,7 +54,7 @@ def format(self, tokensource, outfile):
while token not in self.f_strings:
token = token.parent
o += "%s\x03%s\x04" % (self.f_strings[token], text)
outfile.write(str(parse(o.rstrip())))
outfile.write(parse(o.rstrip()))

class Interp(code.InteractiveInterpreter):
def __init__(self, locals=None):
Expand Down Expand Up @@ -146,6 +146,8 @@ def showtraceback(self):
l[len(l):] = traceback.format_exception_only(type, value)
tbtext = ''.join(l)
lexer = get_lexer_by_name("pytb", stripall=True)


traceback_informative_formatter = BPythonFormatter(default_colors)
traceback_code_formatter = BPythonFormatter({Token: ('d')})
tokens= list(lexer.get_tokens(tbtext))
Expand Down