Commit 688722ce authored by Terry Jan Reedy's avatar Terry Jan Reedy Committed by GitHub

bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)

Using the system and place-dependent default encoding for open()
is a bad idea for IDLE's system and location-independent files.
parent f34e03ec
......@@ -112,7 +112,7 @@ class ViewFunctionTest(unittest.TestCase):
view.ok()
def test_view_file(self):
view = tv.view_file(root, 'Title', __file__, modal=False)
view = tv.view_file(root, 'Title', __file__, 'ascii', modal=False)
self.assertIsInstance(view, tv.ViewWindow)
self.assertIsInstance(view.viewframe, tv.ViewFrame)
get = view.viewframe.textframe.text.get
......@@ -121,7 +121,7 @@ class ViewFunctionTest(unittest.TestCase):
def test_bad_file(self):
# Mock showerror will be used; view_file will return None.
view = tv.view_file(root, 'Title', 'abc.xyz', modal=False)
view = tv.view_file(root, 'Title', 'abc.xyz', 'ascii', modal=False)
self.assertIsNone(view)
self.assertEqual(tv.showerror.title, 'File Load Error')
......@@ -161,7 +161,8 @@ class ButtonClickTest(unittest.TestCase):
def test_view_file_bind_with_button(self):
def _command():
self.called = True
self.view = tv.view_file(root, 'TITLE_FILE', __file__, _utest=True)
self.view = tv.view_file(root, 'TITLE_FILE', __file__,
encoding='ascii', _utest=True)
button = Button(root, text='BUTTON', command=_command)
button.invoke()
self.addCleanup(button.destroy)
......
......@@ -107,7 +107,7 @@ def view_text(parent, title, text, modal=True, _utest=False):
return ViewWindow(parent, title, text, modal, _utest=_utest)
def view_file(parent, title, filename, encoding=None, modal=True, _utest=False):
def view_file(parent, title, filename, encoding, modal=True, _utest=False):
"""Create text viewer for text in filename.
Return error message if file cannot be read. Otherwise calls view_text
......
Using the system and place-dependent default encoding for open() is a bad
idea for IDLE's system and location-independent files.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment