Skip to content

Commit 5e23bc1

Browse files
committed
win32: No more Python 2.3 - use 0xFFFF0000 value directly
1 parent 65e6bab commit 5e23bc1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

roundup/backends/portalocker.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
raise RuntimeError("PortaLocker only defined for nt and posix platforms")
6060

6161
if os.name == 'nt':
62-
# eugh, we want 0xffff0000 here, but python 2.3 won't let us :(
63-
FFFF0000 = -65536
6462
def lock(file, flags):
6563
hfile = msvcrt.get_osfhandle(file.fileno())
6664
# LockFileEx is not supported on all Win32 platforms (Win95, Win98,
@@ -69,7 +67,7 @@ def lock(file, flags):
6967
# Try LockFileEx first, as it has more functionality and handles
7068
# blocking locks more efficiently.
7169
try:
72-
win32file.LockFileEx(hfile, flags, 0, FFFF0000, __overlapped)
70+
win32file.LockFileEx(hfile, flags, 0, 0xFFFF0000, __overlapped)
7371
except win32file.error, e:
7472
import winerror
7573
# Propagate upwards all exceptions other than not-implemented.
@@ -86,14 +84,14 @@ def lock(file, flags):
8684
"locking on Win9x", RuntimeWarning)
8785
# LockFile only supports immediate-fail locking.
8886
if flags & LOCK_NB:
89-
win32file.LockFile(hfile, 0, 0, FFFF0000, 0)
87+
win32file.LockFile(hfile, 0, 0, 0xFFFF0000, 0)
9088
else:
9189
# Emulate a blocking lock with a polling loop.
9290
import time
9391
while 1:
9492
# Attempt a lock.
9593
try:
96-
win32file.LockFile(hfile, 0, 0, FFFF0000, 0)
94+
win32file.LockFile(hfile, 0, 0, 0xFFFF0000, 0)
9795
break
9896
except win32file.error, e:
9997
# Propagate upwards all exceptions other than lock
@@ -110,7 +108,7 @@ def unlock(file):
110108
# WinME).
111109
# If it's not supported, win32file will raise an api_error exception.
112110
try:
113-
win32file.UnlockFileEx(hfile, 0, FFFF0000, __overlapped)
111+
win32file.UnlockFileEx(hfile, 0, 0xFFFF0000, __overlapped)
114112
except win32file.error, e:
115113
import winerror
116114
# Propagate upwards all exceptions other than not-implemented.
@@ -120,7 +118,7 @@ def unlock(file):
120118
# UnlockFileEx is not supported. Use UnlockFile.
121119
# Care: the low/high length params are reversed compared to
122120
# UnLockFileEx.
123-
win32file.UnlockFile(hfile, 0, 0, FFFF0000, 0)
121+
win32file.UnlockFile(hfile, 0, 0, 0xFFFF0000, 0)
124122

125123
elif os.name =='posix':
126124
def lock(file, flags):

0 commit comments

Comments
 (0)