File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 8686EXAMPLE_CONFIG_URL = 'https://raw.githubusercontent.com/bpython/bpython/master/bpython/sample-config'
8787
8888# This is needed for is_nop and should be removed once is_nop is fixed.
89+ # Also needed for pretty-printing exceptions for error messages
8990if py3 :
9091 unicode = str
9192
@@ -570,7 +571,7 @@ def process_control_event(self, e):
570571 self .startup ()
571572 except IOError as e :
572573 self .status_bar .message (
573- _ ('Executing PYTHONSTARTUP failed: %s' ) % (str (e )))
574+ _ ('Executing PYTHONSTARTUP failed: %s' ) % (unicode (e )))
574575
575576 elif isinstance (e , bpythonevents .UndoEvent ):
576577 self .undo (n = e .n )
@@ -1540,7 +1541,7 @@ def show_source(self):
15401541 try :
15411542 source = self .get_source_of_current_name ()
15421543 except SourceNotFound as e :
1543- self .status_bar .message (str (e ))
1544+ self .status_bar .message (unicode (e ))
15441545 else :
15451546 if self .config .highlight_show_source :
15461547 source = format (PythonLexer ().get_tokens (source ),
Original file line number Diff line number Diff line change 5555from bpython .history import History
5656from bpython .translations import _ , ngettext
5757
58+ if py3 : # used for getting pretty-printing exceptions
59+ unicode = str
60+
5861
5962class RuntimeTimer (object ):
6063 def __init__ (self ):
@@ -545,11 +548,11 @@ def get_source_of_current_name(self):
545548 obj = self .get_object (line )
546549 return inspection .get_source_unicode (obj )
547550 except (AttributeError , NameError ) as e :
548- msg = _ ("Cannot get source: %s" ) % (str (e ), )
551+ msg = _ ("Cannot get source: %s" ) % (unicode (e ), )
549552 except IOError as e :
550- msg = str (e )
553+ msg = unicode (e )
551554 except TypeError as e :
552- if "built-in" in str (e ):
555+ if "built-in" in unicode (e ):
553556 msg = _ ("Cannot access source of %r" ) % (obj , )
554557 else :
555558 msg = _ ("No source code found for %s" ) % (self .current_line , )
You can’t perform that action at this time.
0 commit comments