Show More
@@ -2076,9 +2076,9 b' class InteractiveShell(SingletonConfigurable):' | |||
|
2076 | 2076 | """ |
|
2077 | 2077 | val = self.InteractiveTB.stb2text(stb) |
|
2078 | 2078 | try: |
|
2079 | print(val) | |
|
2079 | print(val) | |
|
2080 | 2080 | except UnicodeEncodeError: |
|
2081 | print(val.encode('utf-8', 'backslashreplace').decode()) | |
|
2081 | print(val.encode('utf-8', 'backslashreplace').decode()) | |
|
2082 | 2082 | |
|
2083 | 2083 | def showsyntaxerror(self, filename=None, running_compiled_code=False): |
|
2084 | 2084 | """Display the syntax error that just occurred. |
@@ -449,23 +449,23 b' class InteractiveShellTestCase(unittest.TestCase):' | |||
|
449 | 449 | # Reset the custom exception hook |
|
450 | 450 | ip.set_custom_exc((), None) |
|
451 | 451 | |
|
452 |
@mock.patch( |
|
|
452 | @mock.patch("builtins.print") | |
|
453 | 453 | def test_showtraceback_with_surrogates(self, mocked_print): |
|
454 | 454 | values = [] |
|
455 |
def mock_print_func(value, sep= |
|
|
455 | def mock_print_func(value, sep=" ", end="\n", file=sys.stdout, flush=False): | |
|
456 | 456 | values.append(value) |
|
457 |
if value == chr(0x |
|
|
458 |
raise UnicodeEncodeError("utf-8", chr(0x |
|
|
457 | if value == chr(0xD8FF): | |
|
458 | raise UnicodeEncodeError("utf-8", chr(0xD8FF), 0, 1, "") | |
|
459 | 459 | |
|
460 | 460 | # mock builtins.print |
|
461 | 461 | mocked_print.side_effect = mock_print_func |
|
462 | 462 | |
|
463 |
# ip._showtraceback() is replaced in globalipapp.py. |
|
|
463 | # ip._showtraceback() is replaced in globalipapp.py. | |
|
464 | 464 | # Call original method to test. |
|
465 |
interactiveshell.InteractiveShell._showtraceback(ip, None, None, chr(0x |
|
|
465 | interactiveshell.InteractiveShell._showtraceback(ip, None, None, chr(0xD8FF)) | |
|
466 | 466 | |
|
467 | 467 | self.assertEqual(mocked_print.call_count, 2) |
|
468 |
self.assertEqual(values, [chr(0x |
|
|
468 | self.assertEqual(values, [chr(0xD8FF), "\\ud8ff"]) | |
|
469 | 469 | |
|
470 | 470 | def test_mktempfile(self): |
|
471 | 471 | filename = ip.mktempfile() |
General Comments 0
You need to be logged in to leave comments.
Login now