diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index d87918a..b8c7cd2 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2076,9 +2076,9 @@ class InteractiveShell(SingletonConfigurable): """ val = self.InteractiveTB.stb2text(stb) try: - print(val) + print(val) except UnicodeEncodeError: - print(val.encode('utf-8', 'backslashreplace').decode()) + print(val.encode('utf-8', 'backslashreplace').decode()) def showsyntaxerror(self, filename=None, running_compiled_code=False): """Display the syntax error that just occurred. diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index d1dec20..324599f 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -449,23 +449,23 @@ class InteractiveShellTestCase(unittest.TestCase): # Reset the custom exception hook ip.set_custom_exc((), None) - @mock.patch('builtins.print') + @mock.patch("builtins.print") def test_showtraceback_with_surrogates(self, mocked_print): values = [] - def mock_print_func(value, sep=' ', end='\n', file=sys.stdout, flush=False): + def mock_print_func(value, sep=" ", end="\n", file=sys.stdout, flush=False): values.append(value) - if value == chr(0xd8ff): - raise UnicodeEncodeError("utf-8", chr(0xd8ff), 0, 1, "") + if value == chr(0xD8FF): + raise UnicodeEncodeError("utf-8", chr(0xD8FF), 0, 1, "") # mock builtins.print mocked_print.side_effect = mock_print_func - # ip._showtraceback() is replaced in globalipapp.py. + # ip._showtraceback() is replaced in globalipapp.py. # Call original method to test. - interactiveshell.InteractiveShell._showtraceback(ip, None, None, chr(0xd8ff)) + interactiveshell.InteractiveShell._showtraceback(ip, None, None, chr(0xD8FF)) self.assertEqual(mocked_print.call_count, 2) - self.assertEqual(values, [chr(0xd8ff), '\\ud8ff']) + self.assertEqual(values, [chr(0xD8FF), "\\ud8ff"]) def test_mktempfile(self): filename = ip.mktempfile()