Show More
@@ -472,27 +472,6 b' class KernelMagics(Magics):' | |||||
472 | else: |
|
472 | else: | |
473 | print("Autosave disabled") |
|
473 | print("Autosave disabled") | |
474 |
|
474 | |||
475 | def safe_unicode(e): |
|
|||
476 | """unicode(e) with various fallbacks. Used for exceptions, which may not be |
|
|||
477 | safe to call unicode() on. |
|
|||
478 | """ |
|
|||
479 | try: |
|
|||
480 | return unicode(e) |
|
|||
481 | except UnicodeError: |
|
|||
482 | pass |
|
|||
483 |
|
||||
484 | try: |
|
|||
485 | return py3compat.str_to_unicode(str(e)) |
|
|||
486 | except UnicodeError: |
|
|||
487 | pass |
|
|||
488 |
|
||||
489 | try: |
|
|||
490 | return py3compat.str_to_unicode(repr(e)) |
|
|||
491 | except UnicodeError: |
|
|||
492 | pass |
|
|||
493 |
|
||||
494 | return u'Unrecoverably corrupt evalue' |
|
|||
495 |
|
||||
496 |
|
475 | |||
497 | class ZMQInteractiveShell(InteractiveShell): |
|
476 | class ZMQInteractiveShell(InteractiveShell): | |
498 | """A subclass of InteractiveShell for ZMQ.""" |
|
477 | """A subclass of InteractiveShell for ZMQ.""" | |
@@ -572,7 +551,7 b' class ZMQInteractiveShell(InteractiveShell):' | |||||
572 | exc_content = { |
|
551 | exc_content = { | |
573 | u'traceback' : stb, |
|
552 | u'traceback' : stb, | |
574 | u'ename' : unicode(etype.__name__), |
|
553 | u'ename' : unicode(etype.__name__), | |
575 | u'evalue' : safe_unicode(evalue) |
|
554 | u'evalue' : py3compat.safe_unicode(evalue), | |
576 | } |
|
555 | } | |
577 |
|
556 | |||
578 | dh = self.displayhook |
|
557 | dh = self.displayhook |
@@ -50,6 +50,27 b' def _modify_str_or_docstring(str_change_func):' | |||||
50 | return doc |
|
50 | return doc | |
51 | return wrapper |
|
51 | return wrapper | |
52 |
|
52 | |||
|
53 | def safe_unicode(e): | |||
|
54 | """unicode(e) with various fallbacks. Used for exceptions, which may not be | |||
|
55 | safe to call unicode() on. | |||
|
56 | """ | |||
|
57 | try: | |||
|
58 | return unicode(e) | |||
|
59 | except UnicodeError: | |||
|
60 | pass | |||
|
61 | ||||
|
62 | try: | |||
|
63 | return py3compat.str_to_unicode(str(e)) | |||
|
64 | except UnicodeError: | |||
|
65 | pass | |||
|
66 | ||||
|
67 | try: | |||
|
68 | return py3compat.str_to_unicode(repr(e)) | |||
|
69 | except UnicodeError: | |||
|
70 | pass | |||
|
71 | ||||
|
72 | return u'Unrecoverably corrupt evalue' | |||
|
73 | ||||
53 | if sys.version_info[0] >= 3: |
|
74 | if sys.version_info[0] >= 3: | |
54 | PY3 = True |
|
75 | PY3 = True | |
55 |
|
76 |
General Comments 0
You need to be logged in to leave comments.
Login now