https://github.com/python/cpython/commit/10a8ff2bc49bdaa2db47108c8e5cdc199ebadb4c
commit: 10a8ff2bc49bdaa2db47108c8e5cdc199ebadb4c
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: terryjreedy <[email protected]>
date: 2026-09-24T20:55:00-04:00
summary:

[3.14] gh-158067: Keep Python files first in IDLE Open dialog from Shell 
(GH-158071) (#158142)

gh-158067: Keep Python files first in IDLE Open dialog from Shell (GH-158071)

Fix regression in July releases.
(cherry picked from commit e08b0d48d24e873c8cfb0e2a30b0df576b7727dc)

Co-authored-by: Lazizbek Ergashev <[email protected]>

files:
A Misc/NEWS.d/next/IDLE/2026-09-24-12-00-00.gh-issue-158067.opnPy1.rst
M Lib/idlelib/idle_test/test_outwin.py
M Lib/idlelib/iomenu.py
M Lib/idlelib/outwin.py

diff --git a/Lib/idlelib/idle_test/test_outwin.py 
b/Lib/idlelib/idle_test/test_outwin.py
index 00a7432b908873..667c1667465c3a 100644
--- a/Lib/idlelib/idle_test/test_outwin.py
+++ b/Lib/idlelib/idle_test/test_outwin.py
@@ -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):
+        # 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())
diff --git a/Lib/idlelib/iomenu.py b/Lib/idlelib/iomenu.py
index 96bf6078f12c3e..c2412e98fb9c4d 100644
--- a/Lib/idlelib/iomenu.py
+++ b/Lib/idlelib/iomenu.py
@@ -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"),
@@ -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
diff --git a/Lib/idlelib/outwin.py b/Lib/idlelib/outwin.py
index f7e92bb8ac0c77..b9dfeef173637c 100644
--- a/Lib/idlelib/outwin.py
+++ b/Lib/idlelib/outwin.py
@@ -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
diff --git 
a/Misc/NEWS.d/next/IDLE/2026-09-24-12-00-00.gh-issue-158067.opnPy1.rst 
b/Misc/NEWS.d/next/IDLE/2026-09-24-12-00-00.gh-issue-158067.opnPy1.rst
new file mode 100644
index 00000000000000..2e34cf6a67b827
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2026-09-24-12-00-00.gh-issue-158067.opnPy1.rst
@@ -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.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to