From 792acaa5ef018c981bab51a5f50fbe8bceb58e1a Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 9 Oct 2025 12:54:02 +0100 Subject: [PATCH 1/5] Commit --- Lib/idlelib/CREDITS.txt | 1 + Lib/idlelib/editor.py | 6 +++--- Lib/idlelib/pyshell.py | 3 +-- .../next/IDLE/2025-10-09-12-53-47.gh-issue-96491.4YKxvy.rst | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/IDLE/2025-10-09-12-53-47.gh-issue-96491.4YKxvy.rst diff --git a/Lib/idlelib/CREDITS.txt b/Lib/idlelib/CREDITS.txt index bea3ba7c20de22..1b853e8cc1c462 100644 --- a/Lib/idlelib/CREDITS.txt +++ b/Lib/idlelib/CREDITS.txt @@ -37,6 +37,7 @@ Major contributors since 2005: - 2014: Saimadhav Heblikar - 2015: Mark Roseman - 2017: Louie Lu, Cheryl Sabella, and Serhiy Storchaka +- 2025: Stan Ulbrych For additional details refer to NEWS.txt and Changelog. diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index b4d6d25871bcf4..b9d0ca135bcf97 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1013,11 +1013,11 @@ def saved_change_hook(self): # that doesn't match platform conventions. title = short + " - " + long + _py_version elif short: - title = short + title = short + _py_version elif long: - title = long + title = long + _py_version else: - title = "untitled" + title = "untitled" + _py_version icon = short or long or title if not self.get_saved(): title = "*%s*" % title diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 74a0e03994f69a..1b7c2af1a923d7 100755 --- a/Lib/idlelib/pyshell.py +++ b/Lib/idlelib/pyshell.py @@ -22,7 +22,6 @@ import linecache import os import os.path -from platform import python_version import re import socket import subprocess @@ -841,7 +840,7 @@ def display_executing_dialog(self): class PyShell(OutputWindow): from idlelib.squeezer import Squeezer - shell_title = "IDLE Shell " + python_version() + shell_title = "IDLE Shell" # Override classes ColorDelegator = ModifiedColorDelegator diff --git a/Misc/NEWS.d/next/IDLE/2025-10-09-12-53-47.gh-issue-96491.4YKxvy.rst b/Misc/NEWS.d/next/IDLE/2025-10-09-12-53-47.gh-issue-96491.4YKxvy.rst new file mode 100644 index 00000000000000..beb6ef5ade562f --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2025-10-09-12-53-47.gh-issue-96491.4YKxvy.rst @@ -0,0 +1 @@ +Deduplicate version number in IDLE shell title bar after saving to a file. From c72bb2c075665e1f27360644bb0a61b29463f714 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 9 Oct 2025 13:20:12 +0100 Subject: [PATCH 2/5] Commit --- Lib/idlelib/editor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index b9d0ca135bcf97..898fa49115ba84 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1013,11 +1013,14 @@ def saved_change_hook(self): # that doesn't match platform conventions. title = short + " - " + long + _py_version elif short: - title = short + _py_version + if short == "IDLE Shell": + title = short + _py_version + else: + title = short elif long: - title = long + _py_version + title = long else: - title = "untitled" + _py_version + title = "untitled" icon = short or long or title if not self.get_saved(): title = "*%s*" % title From bceaa99bd684532fd28491c5d3962c9928e94155 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Fri, 10 Oct 2025 16:18:29 +0100 Subject: [PATCH 3/5] Terry's review --- Lib/idlelib/editor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 898fa49115ba84..aa57da10b98e53 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -33,7 +33,6 @@ # The default tab setting for a Text widget, in average-width characters. TK_TABWIDTH_DEFAULT = 8 -_py_version = ' (%s)' % platform.python_version() darwin = sys.platform == 'darwin' def _sphinx_version(): @@ -1008,15 +1007,16 @@ def open_recent_file(fn_closure=file_name): def saved_change_hook(self): short = self.short_title() long = self.long_title() + _py_version = ' (%s)' % platform.python_version() if short and long and not macosx.isCocoaTk(): # Don't use both values on macOS because # that doesn't match platform conventions. title = short + " - " + long + _py_version elif short: if short == "IDLE Shell": - title = short + _py_version + title = short + platform.python_version() else: - title = short + title = short + _py_version elif long: title = long else: From 35d3e2950a998c8e226293e02af1df77cff3591a Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Fri, 10 Oct 2025 16:35:22 +0100 Subject: [PATCH 4/5] Fix test --- Lib/idlelib/idle_test/test_outwin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/idle_test/test_outwin.py b/Lib/idlelib/idle_test/test_outwin.py index 81f4aad7e95e95..0f13363f84f361 100644 --- a/Lib/idlelib/idle_test/test_outwin.py +++ b/Lib/idlelib/idle_test/test_outwin.py @@ -1,6 +1,7 @@ "Test outwin, coverage 76%." from idlelib import outwin +import platform import sys import unittest from test.support import requires @@ -41,7 +42,7 @@ def test_ispythonsource(self): self.assertFalse(w.ispythonsource(__file__)) def test_window_title(self): - self.assertEqual(self.window.top.title(), 'Output') + self.assertEqual(self.window.top.title(), 'Output' + ' (%s)' % platform.python_version()) def test_maybesave(self): w = self.window From 4496374bce52d51a3e0f9f8b129fd6ba0a678883 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 10 Oct 2025 18:47:56 -0400 Subject: [PATCH 5/5] Add space. --- Lib/idlelib/editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index aa57da10b98e53..83112d85575e47 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1014,7 +1014,7 @@ def saved_change_hook(self): title = short + " - " + long + _py_version elif short: if short == "IDLE Shell": - title = short + platform.python_version() + title = short + " " + platform.python_version() else: title = short + _py_version elif long: