Skip to content

GH-88564: IDLE - fix 2 Edit menu hotkey displays#99743

Open
terryjreedy wants to merge 1 commit intopython:mainfrom
terryjreedy:mackey
Open

GH-88564: IDLE - fix 2 Edit menu hotkey displays#99743
terryjreedy wants to merge 1 commit intopython:mainfrom
terryjreedy:mackey

Conversation

@terryjreedy
Copy link
Copy Markdown
Member

@terryjreedy terryjreedy commented Nov 24, 2022

On Mac Cocoa, ^+backspace and ^+space were mis-displayed as ^B and ^S. Replace 'backslash' with '' everywhere, just as 'slash', for example, is replaced with '/'. On Mac Cocoa, change 'space' to 'Space', which then displays as 'Space' instead of 'S'. ('Space' is also used for the Mac-specific Emoji & Symbols entry.)

Co-authored by ronaldoussoren

On Mac Cocoa, ^+backspace and ^+space were misdisplayed
as ^B and ^S. Replace 'backslash' with '\' everywhere,
just as 'slash', for example, is replaced with '/'.
On Mac Cocoa, change'space' to 'Space', which then displays
as 'Space' instead of 'S'.  ('Space' is also used for the
Mac-specific Emoji & Symbols entry.)
@terryjreedy
Copy link
Copy Markdown
Member Author

@ronaldoussoren Besides Windows, I tested this on Catalina by editing installed editor.py. Is the space-> Space fix only needed for Cocoa?

@terryjreedy
Copy link
Copy Markdown
Member Author

The test failure is hanging for 20 minutes in
test_case_soft_keyword (idlelib.idle_test.test_colorizer.ColorDelegatorTest.test_case_soft_keyword) .
I tested python3.x -m test.test_idle -v on my MacBook Air and got the same failure even with the 2 new lines commented out and with 3.11 and 3.10. I am baffled.
@ned-deily You have any ideas either?

@ronaldoussoren
Copy link
Copy Markdown
Contributor

This PR does not work for me. If I manually apply the patch to an installed copy of Python 3.12 IDLE crashes when I try to open the Edit menu ("segmentation fault"). Reverting the patch fixes the crash.

The crash report has a stack trace somewhere deep inside system frameworks with Tk on the call stack.

The fix is likely only needed for Cocoa, otherwise we'd have reports from other platforms as well. But that's not something I can test, I can only test using the copy of Tk shipped with out installers.

@hugovk hugovk removed the needs backport to 3.10 only security fixes label Apr 7, 2023
@terryjreedy
Copy link
Copy Markdown
Member Author

PR not working right yet.

Copy link
Copy Markdown
Contributor

@ronaldoussoren ronaldoussoren left a comment

Choose a reason for hiding this comment

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

I've tested this PR with a slight modification to make it work on top of #113513:

diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 8bf517d41f..36fde4af73 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -1678,6 +1678,7 @@ def prepstr(s):
  'bracketleft': '[',
  'bracketright': ']',
  'slash': '/',
+ 'backslash': '\\',
 }
 
 def get_accelerator(keydefs, eventname):
diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
index 8637e8ebf2..60c58d59a3 100644
--- a/Lib/idlelib/macosx.py
+++ b/Lib/idlelib/macosx.py
@@ -263,6 +263,8 @@ def setupApp(root, flist):
     global _idle_root
     _idle_root = root
     if isAquaTk():
+        from idlelib import editor
+        editor.keynames["space"] = "Space"
         hideTkConsole(root)
         overrideRootMenu(root, flist)
         addOpenEventSupport(root, flist)

That PR makes it an error to call isAquaTk before macosx.setupApp is called to avoid problems with Tk Aqua (see that PR for background).

The menu now looks correct, and I've tested that the shortcuts work as well:

image

My change to the diff should work both with and without #113513. Please move setting idlelib.editor.keynames['space'] to macosx.setupApp as in the diff above to avoid creating merge conflict when that PR is merged.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Dec 29, 2023

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@ronaldoussoren ronaldoussoren added the needs backport to 3.12 only security fixes label Dec 31, 2023
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes and removed needs backport to 3.11 only security fixes labels May 9, 2024
@tomasr8 tomasr8 removed the needs backport to 3.12 only security fixes label Apr 10, 2025
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 8, 2025
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes DO-NOT-MERGE needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants