Skip to content

Commit 9882a9e

Browse files
committed
Remove 'import *' statement from roundup/backends/portalocker.py
There are various 'import *' statements scattered through the code which are generally not a good thing. These should be fairly safe changes, but I'll commit them one file at a time to make it easier to track down issues with a bisect if they crop up later.
1 parent 6c3d318 commit 9882a9e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

roundup/backends/portalocker.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
if os.name == 'nt':
5555
import msvcrt
56-
from ctypes import *
56+
import ctypes
5757
from ctypes.wintypes import BOOL, DWORD, HANDLE
5858

5959
LOCK_SH = 0 # the default
@@ -64,34 +64,34 @@
6464
#
6565
# detect size of ULONG_PTR
6666
def is_64bit():
67-
return sizeof(c_ulong) != sizeof(c_void_p)
67+
return ctypes.sizeof(ctypes.c_ulong) != ctypes.sizeof(ctypes.c_void_p)
6868
if is_64bit():
69-
ULONG_PTR = c_int64
69+
ULONG_PTR = ctypes.c_int64
7070
else:
71-
ULONG_PTR = c_ulong
72-
PVOID = c_void_p
71+
ULONG_PTR = ctypes.c_ulong
72+
PVOID = ctypes.c_void_p
7373

7474
# --- Union inside Structure by stackoverflow:3480240 ---
75-
class _OFFSET(Structure):
75+
class _OFFSET(ctypes.Structure):
7676
_fields_ = [
7777
('Offset', DWORD),
7878
('OffsetHigh', DWORD)]
7979

80-
class _OFFSET_UNION(Union):
80+
class _OFFSET_UNION(ctypes.Union):
8181
_anonymous_ = ['_offset']
8282
_fields_ = [
8383
('_offset', _OFFSET),
8484
('Pointer', PVOID)]
8585

86-
class OVERLAPPED(Structure):
86+
class OVERLAPPED(ctypes.Structure):
8787
_anonymous_ = ['_offset_union']
8888
_fields_ = [
8989
('Internal', ULONG_PTR),
9090
('InternalHigh', ULONG_PTR),
9191
('_offset_union', _OFFSET_UNION),
9292
('hEvent', HANDLE)]
9393

94-
LPOVERLAPPED = POINTER(OVERLAPPED)
94+
LPOVERLAPPED = ctypes.POINTER(OVERLAPPED)
9595

9696
# --- Define function prototypes for extra safety ---
9797
LockFileEx = windll.kernel32.LockFileEx
@@ -114,15 +114,15 @@ def lock(file, flags):
114114
""" Return True on success, False otherwise """
115115
hfile = msvcrt.get_osfhandle(file.fileno())
116116
overlapped = OVERLAPPED()
117-
if LockFileEx(hfile, flags, 0, 0, 0xFFFF0000, byref(overlapped)):
117+
if LockFileEx(hfile, flags, 0, 0, 0xFFFF0000, ctypes.byref(overlapped)):
118118
return True
119119
else:
120120
return False
121121

122122
def unlock(file):
123123
hfile = msvcrt.get_osfhandle(file.fileno())
124124
overlapped = OVERLAPPED()
125-
if UnlockFileEx(hfile, 0, 0, 0xFFFF0000, byref(overlapped)):
125+
if UnlockFileEx(hfile, 0, 0, 0xFFFF0000, ctypes.byref(overlapped)):
126126
return True
127127
else:
128128
return False

0 commit comments

Comments
 (0)