summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/idlelib/NEWS.txt5
-rw-r--r--Lib/idlelib/macosx.py42
-rw-r--r--Misc/NEWS.d/next/IDLE/2022-10-15-21-20-40.gh-issue-97527.otAHJM.rst3
3 files changed, 34 insertions, 16 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 7fa7fac..e64e96f 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -4,6 +4,11 @@ Released on 2022-10-03
=========================
+gh-97527: Fix a bug in the previous bugfix that caused IDLE to not
+start when run with 3.10.8, 3.12.0a1, and at least Microsoft Python
+3.10.2288.0 installed without the Lib/test package. 3.11.0 was never
+affected.
+
gh-65802: Document handling of extensions in Save As dialogs.
gh-95191: Include prompts when saving Shell (interactive input/output).
diff --git a/Lib/idlelib/macosx.py b/Lib/idlelib/macosx.py
index 12399f1..89b6457 100644
--- a/Lib/idlelib/macosx.py
+++ b/Lib/idlelib/macosx.py
@@ -4,7 +4,6 @@ A number of functions that enhance IDLE on macOS.
from os.path import expanduser
import plistlib
from sys import platform # Used in _init_tk_type, changed by test.
-from test.support import requires, ResourceDenied
import tkinter
@@ -16,27 +15,38 @@ _tk_type = None
def _init_tk_type():
""" Initialize _tk_type for isXyzTk functions.
+
+ This function is only called once, when _tk_type is still None.
"""
global _tk_type
if platform == 'darwin':
- try:
- requires('gui')
- except ResourceDenied: # Possible when testing.
- _tk_type = "cocoa" # Newest and most common.
- else:
- root = tkinter.Tk()
- ws = root.tk.call('tk', 'windowingsystem')
- if 'x11' in ws:
- _tk_type = "xquartz"
- elif 'aqua' not in ws:
- _tk_type = "other"
- elif 'AppKit' in root.tk.call('winfo', 'server', '.'):
+
+ # When running IDLE, GUI is present, test/* may not be.
+ # When running tests, test/* is present, GUI may not be.
+ # If not, guess most common. Does not matter for testing.
+ from idlelib.__init__ import testing
+ if testing:
+ from test.support import requires, ResourceDenied
+ try:
+ requires('gui')
+ except ResourceDenied:
_tk_type = "cocoa"
- else:
- _tk_type = "carbon"
- root.destroy()
+ return
+
+ root = tkinter.Tk()
+ ws = root.tk.call('tk', 'windowingsystem')
+ if 'x11' in ws:
+ _tk_type = "xquartz"
+ elif 'aqua' not in ws:
+ _tk_type = "other"
+ elif 'AppKit' in root.tk.call('winfo', 'server', '.'):
+ _tk_type = "cocoa"
+ else:
+ _tk_type = "carbon"
+ root.destroy()
else:
_tk_type = "other"
+ return
def isAquaTk():
"""
diff --git a/Misc/NEWS.d/next/IDLE/2022-10-15-21-20-40.gh-issue-97527.otAHJM.rst b/Misc/NEWS.d/next/IDLE/2022-10-15-21-20-40.gh-issue-97527.otAHJM.rst
new file mode 100644
index 0000000..e7fda89
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2022-10-15-21-20-40.gh-issue-97527.otAHJM.rst
@@ -0,0 +1,3 @@
+Fix a bug in the previous bugfix that caused IDLE to not start when run with
+3.10.8, 3.12.0a1, and at least Microsoft Python 3.10.2288.0 installed
+without the Lib/test package. 3.11.0 was never affected.