gh-96491: Deduplicate version in IDLE shell title (#139841)

Saving to a file added both the filename and repeated the version.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Stan Ulbrych 2025-10-11 02:37:48 +01:00 committed by GitHub
parent ff7bb565d8
commit d4e5802588
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 10 additions and 5 deletions

View file

@ -37,6 +37,7 @@ Major contributors since 2005:
- 2014: Saimadhav Heblikar - 2014: Saimadhav Heblikar
- 2015: Mark Roseman - 2015: Mark Roseman
- 2017: Louie Lu, Cheryl Sabella, and Serhiy Storchaka - 2017: Louie Lu, Cheryl Sabella, and Serhiy Storchaka
- 2025: Stan Ulbrych
For additional details refer to NEWS.txt and Changelog. For additional details refer to NEWS.txt and Changelog.

View file

@ -33,7 +33,6 @@
# The default tab setting for a Text widget, in average-width characters. # The default tab setting for a Text widget, in average-width characters.
TK_TABWIDTH_DEFAULT = 8 TK_TABWIDTH_DEFAULT = 8
_py_version = ' (%s)' % platform.python_version()
darwin = sys.platform == 'darwin' darwin = sys.platform == 'darwin'
def _sphinx_version(): def _sphinx_version():
@ -1008,12 +1007,16 @@ def open_recent_file(fn_closure=file_name):
def saved_change_hook(self): def saved_change_hook(self):
short = self.short_title() short = self.short_title()
long = self.long_title() long = self.long_title()
_py_version = ' (%s)' % platform.python_version()
if short and long and not macosx.isCocoaTk(): if short and long and not macosx.isCocoaTk():
# Don't use both values on macOS because # Don't use both values on macOS because
# that doesn't match platform conventions. # that doesn't match platform conventions.
title = short + " - " + long + _py_version title = short + " - " + long + _py_version
elif short: elif short:
title = short if short == "IDLE Shell":
title = short + " " + platform.python_version()
else:
title = short + _py_version
elif long: elif long:
title = long title = long
else: else:

View file

@ -1,6 +1,7 @@
"Test outwin, coverage 76%." "Test outwin, coverage 76%."
from idlelib import outwin from idlelib import outwin
import platform
import sys import sys
import unittest import unittest
from test.support import requires from test.support import requires
@ -41,7 +42,7 @@ def test_ispythonsource(self):
self.assertFalse(w.ispythonsource(__file__)) self.assertFalse(w.ispythonsource(__file__))
def test_window_title(self): 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): def test_maybesave(self):
w = self.window w = self.window

View file

@ -22,7 +22,6 @@
import linecache import linecache
import os import os
import os.path import os.path
from platform import python_version
import re import re
import socket import socket
import subprocess import subprocess
@ -841,7 +840,7 @@ def display_executing_dialog(self):
class PyShell(OutputWindow): class PyShell(OutputWindow):
from idlelib.squeezer import Squeezer from idlelib.squeezer import Squeezer
shell_title = "IDLE Shell " + python_version() shell_title = "IDLE Shell"
# Override classes # Override classes
ColorDelegator = ModifiedColorDelegator ColorDelegator = ModifiedColorDelegator

View file

@ -0,0 +1 @@
Deduplicate version number in IDLE shell title bar after saving to a file.