Skip to content

Commit 77e0abe

Browse files
bpo-33656: Move pyshell ctypes import inside try block. (GH-9858)
A Windows build with _tkinter, tkinter, and idlelib but without ctypes is unlikely but apparently possible. (cherry picked from commit d274afb) Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 6a1238c commit 77e0abe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/idlelib/pyshell.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# Valid arguments for the ...Awareness call below are defined in the following.
1313
# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx
1414
if sys.platform == 'win32':
15-
import ctypes
16-
PROCESS_SYSTEM_DPI_AWARE = 1
1715
try:
16+
import ctypes
17+
PROCESS_SYSTEM_DPI_AWARE = 1
1818
ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
19-
except (AttributeError, OSError):
19+
except (ImportError, AttributeError, OSError):
2020
pass
2121

2222
import tkinter.messagebox as tkMessageBox

0 commit comments

Comments
 (0)