11from ctypes import *
2+ import ctypes
23import os
34import shutil
45import subprocess
@@ -72,18 +73,18 @@ def test_load_library(self):
7273 print (find_library ("user32" ))
7374
7475 if os .name == "nt" :
75- windll .kernel32 .GetModuleHandleW
76- windll ["kernel32" ].GetModuleHandleW
77- windll .LoadLibrary ("kernel32" ).GetModuleHandleW
78- WinDLL ("kernel32" ).GetModuleHandleW
76+ ctypes . windll .kernel32 .GetModuleHandleW
77+ ctypes . windll ["kernel32" ].GetModuleHandleW
78+ ctypes . windll .LoadLibrary ("kernel32" ).GetModuleHandleW
79+ ctypes . WinDLL ("kernel32" ).GetModuleHandleW
7980 # embedded null character
80- self .assertRaises (ValueError , windll .LoadLibrary , "kernel32\0 " )
81+ self .assertRaises (ValueError , ctypes . windll .LoadLibrary , "kernel32\0 " )
8182
8283 @unittest .skipUnless (os .name == "nt" ,
8384 'test specific to Windows' )
8485 def test_load_ordinal_functions (self ):
8586 import _ctypes_test
86- dll = WinDLL (_ctypes_test .__file__ )
87+ dll = ctypes . WinDLL (_ctypes_test .__file__ )
8788 # We load the same function both via ordinal and name
8889 func_ord = dll [2 ]
8990 func_name = dll .GetString
@@ -114,14 +115,16 @@ def test_1703286_B(self):
114115 # also has a high address. 'call_function' should accept
115116 # addresses so large.
116117 from _ctypes import call_function
117- advapi32 = windll .advapi32
118+
119+ advapi32 = ctypes .windll .advapi32
118120 # Calling CloseEventLog with a NULL argument should fail,
119121 # but the call should not segfault or so.
120122 self .assertEqual (0 , advapi32 .CloseEventLog (None ))
121- windll .kernel32 .GetProcAddress .argtypes = c_void_p , c_char_p
122- windll .kernel32 .GetProcAddress .restype = c_void_p
123- proc = windll .kernel32 .GetProcAddress (advapi32 ._handle ,
124- b"CloseEventLog" )
123+
124+ kernel32 = ctypes .windll .kernel32
125+ kernel32 .GetProcAddress .argtypes = c_void_p , c_char_p
126+ kernel32 .GetProcAddress .restype = c_void_p
127+ proc = kernel32 .GetProcAddress (advapi32 ._handle , b"CloseEventLog" )
125128 self .assertTrue (proc )
126129 # This is the real test: call the function via 'call_function'
127130 self .assertEqual (0 , call_function (proc , (None ,)))
@@ -130,7 +133,7 @@ def test_1703286_B(self):
130133 'test specific to Windows' )
131134 def test_load_hasattr (self ):
132135 # bpo-34816: shouldn't raise OSError
133- self .assertFalse (hasattr (windll , 'test' ))
136+ self .assertFalse (hasattr (ctypes . windll , 'test' ))
134137
135138 @unittest .skipUnless (os .name == "nt" ,
136139 'test specific to Windows' )
0 commit comments