Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe8db63

Browse files
gh-97527: IDLE: protect macosx Tk() call when no GUI (GH-97530)
Only call tkinter.tk and its follow-up code in _init_tk_type when requires('gui')does not raise. This function can be called as an unintended side-effect ofcalling other idlelib code as part of tests on macOS without a GUI enabled.(cherry picked from commit9704f8d)Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parentc2916d2 commitfe8db63

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

‎Lib/idlelib/macosx.py‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
fromos.pathimportexpanduser
55
importplistlib
66
fromsysimportplatform# Used in _init_tk_type, changed by test.
7+
fromtest.supportimportrequires,ResourceDenied
78

89
importtkinter
910

@@ -14,23 +15,26 @@
1415
_tk_type=None
1516

1617
def_init_tk_type():
17-
"""
18-
Initializes OS X Tk variant values for
19-
isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz().
18+
""" Initialize _tk_type for isXyzTk functions.
2019
"""
2120
global_tk_type
2221
ifplatform=='darwin':
23-
root=tkinter.Tk()
24-
ws=root.tk.call('tk','windowingsystem')
25-
if'x11'inws:
26-
_tk_type="xquartz"
27-
elif'aqua'notinws:
28-
_tk_type="other"
29-
elif'AppKit'inroot.tk.call('winfo','server','.'):
30-
_tk_type="cocoa"
22+
try:
23+
requires('gui')
24+
exceptResourceDenied:# Possible when testing.
25+
_tk_type="cocoa"# Newest and most common.
3126
else:
32-
_tk_type="carbon"
33-
root.destroy()
27+
root=tkinter.Tk()
28+
ws=root.tk.call('tk','windowingsystem')
29+
if'x11'inws:
30+
_tk_type="xquartz"
31+
elif'aqua'notinws:
32+
_tk_type="other"
33+
elif'AppKit'inroot.tk.call('winfo','server','.'):
34+
_tk_type="cocoa"
35+
else:
36+
_tk_type="carbon"
37+
root.destroy()
3438
else:
3539
_tk_type="other"
3640

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp