Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Lib/idlelib/idle_test/test_outwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def test_save_defaults_to_text(self):
io = self.window.io
self.assertEqual(io.defaultextension, '.txt')
# Text files are offered before Python files.
self.assertEqual(io.filetypes[0][0], 'Text files')
self.assertEqual(io.save_filetypes[0][0], 'Text files')

def test_open_defaults_to_python(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not really test what we want to know, which is what the user sees when the select the menu item or give the shortcut key. The same is true of the test above. Both would require generating the event and mocking the dialog call. Possible, but I tested this in live IDLE and want to fix the regression now, before the next releases in a week. And I have other pr to review for inclusion. So I will merge as is.

# gh-158067: File Open still lists Python files first.
self.assertEqual(self.window.io.filetypes[0][0], 'Python files')

def test_window_title(self):
self.assertEqual(self.window.top.title(), 'Output' + ' (%s)' % platform.python_version())
Expand Down
8 changes: 5 additions & 3 deletions Lib/idlelib/iomenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,10 @@ def print_window(self, event):
("All files", "*"),
)

# Output windows (Shell, Output) are not Python source, so they list
# text files first and default to ".txt" (gh-65339).
save_filetypes = filetypes

# Output windows (Shell, Output) are not Python source, so they save
# with text files listed first and default to ".txt" (gh-65339).
text_filetypes = (
("Text files", "*.txt", "TEXT"),
("Python files", py_extensions, "TEXT"),
Expand Down Expand Up @@ -427,7 +429,7 @@ def asksavefile(self):
if not self.savedialog:
self.savedialog = filedialog.SaveAs(
parent=self.text,
filetypes=self.filetypes,
filetypes=self.save_filetypes,
defaultextension=self.defaultextension)
filename = self.savedialog.show(initialdir=dir, initialfile=base)
return filename
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/outwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, *args):
self.text.bind("<<goto-file-line>>", self.goto_file_line)
# Output is not Python source, so save it as text by default
# (gh-65339).
self.io.filetypes = self.io.text_filetypes
self.io.save_filetypes = self.io.text_filetypes
self.io.defaultextension = self.io.text_defaultextension

# Customize EditorWindow
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix the IDLE File Open dialog listing text files before Python files when
opened from the Shell or an Output window.
Loading