]> granicus.if.org Git - python/commitdiff
bpo-33656: Move pyshell ctypes import inside try block. (GH-9858)
authorTerry Jan Reedy <tjreedy@udel.edu>
Sun, 14 Oct 2018 00:00:31 +0000 (20:00 -0400)
committerGitHub <noreply@github.com>
Sun, 14 Oct 2018 00:00:31 +0000 (20:00 -0400)
A Windows build with _tkinter, tkinter, and idlelib
but without ctypes is unlikely but apparently possible.

Lib/idlelib/pyshell.py

index 5458c59dbd7e0b81398e37573965dfef2d06b255..47eef4399ce6b3654f6954126f1fe339fecb0af0 100755 (executable)
@@ -12,11 +12,11 @@ except ImportError:
 # Valid arguments for the ...Awareness call below are defined in the following.
 # https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx
 if sys.platform == 'win32':
-    import ctypes
-    PROCESS_SYSTEM_DPI_AWARE = 1
     try:
+        import ctypes
+        PROCESS_SYSTEM_DPI_AWARE = 1
         ctypes.OleDLL('shcore').SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
-    except (AttributeError, OSError):
+    except (ImportError, AttributeError, OSError):
         pass
 
 import tkinter.messagebox as tkMessageBox