Skip to content

Commit b6ea7e8

Browse files
author
Richard Jones
committed
nicer work-around for the 32-bit int problem
1 parent ad8887e commit b6ea7e8

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

roundup/backends/locking.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,14 @@
1919
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
# SOFTWARE.
2121

22-
# $Id: locking.py,v 1.4 2003-02-06 09:40:21 richard Exp $
22+
# $Id: locking.py,v 1.5 2003-02-14 00:08:32 richard Exp $
2323

2424
'''This module provides a generic interface to acquire and release
2525
exclusive access to a file.
2626
2727
It should work on Unix and Windows.
2828
'''
2929

30-
try:
31-
x=FutureWarning
32-
import warnings
33-
warnings.filterwarnings("ignore",
34-
r'hex/oct constants > sys\.maxint .*', FutureWarning,
35-
'portalocker', 0)
36-
del x
37-
except:
38-
pass
39-
4030
import portalocker
4131

4232
def acquire_lock(path, block=1):

roundup/backends/portalocker.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Requires python 1.5.2 or better.
33

44
# ID line added by richard for Roundup file tracking
5-
# $Id: portalocker.py,v 1.3 2003-01-19 23:14:42 richard Exp $
5+
# $Id: portalocker.py,v 1.4 2003-02-14 00:08:32 richard Exp $
66

77
""" Cross-platform (posix/nt) API for flock-style file locking.
88
@@ -67,7 +67,7 @@ def lock(file, flags):
6767
# Try LockFileEx first, as it has more functionality and handles
6868
# blocking locks more efficiently.
6969
try:
70-
win32file.LockFileEx(hfile, flags, 0, 0xffff0000, __overlapped)
70+
win32file.LockFileEx(hfile, flags, 0, 0xffff0000L, __overlapped)
7171
except win32file.error, e:
7272
import winerror
7373
# Propagate upwards all exceptions other than not-implemented.
@@ -82,14 +82,14 @@ def lock(file, flags):
8282
warnings.warn("PortaLocker does not support shared locking on Win9x", RuntimeWarning)
8383
# LockFile only supports immediate-fail locking.
8484
if flags & LOCK_NB:
85-
win32file.LockFile(hfile, 0, 0, 0xffff0000, 0)
85+
win32file.LockFile(hfile, 0, 0, 0xffff0000L, 0)
8686
else:
8787
# Emulate a blocking lock with a polling loop.
8888
import time
8989
while 1:
9090
# Attempt a lock.
9191
try:
92-
win32file.LockFile(hfile, 0, 0, 0xffff0000, 0)
92+
win32file.LockFile(hfile, 0, 0, 0xffff0000L, 0)
9393
break
9494
except win32file.error, e:
9595
# Propagate upwards all exceptions other than lock violation.
@@ -104,7 +104,7 @@ def unlock(file):
104104
# UnlockFileEx is not supported on all Win32 platforms (Win95, Win98, WinME).
105105
# If it's not supported, win32file will raise an api_error exception.
106106
try:
107-
win32file.UnlockFileEx(hfile, 0, 0xffff0000, __overlapped)
107+
win32file.UnlockFileEx(hfile, 0, 0xffff0000L, __overlapped)
108108
except win32file.error, e:
109109
import winerror
110110
# Propagate upwards all exceptions other than not-implemented.
@@ -113,7 +113,7 @@ def unlock(file):
113113

114114
# UnlockFileEx is not supported. Use UnlockFile.
115115
# Care: the low/high length params are reversed compared to UnLockFileEx.
116-
win32file.UnlockFile(hfile, 0, 0, 0xffff0000, 0)
116+
win32file.UnlockFile(hfile, 0, 0, 0xffff0000L, 0)
117117

118118
elif os.name =='posix':
119119
def lock(file, flags):

0 commit comments

Comments
 (0)