Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91221c2

Browse files
committed
Support for netbsd1 and freebsd3, after suggestions by Anders Andersen
and Jacques Vidrine.
1 parent c0f29c2 commit 91221c2

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lib/posixfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def lock(self, how, *args):
177177
# Hack by [email protected] to get locking to go on freebsd;
178178
# additions for AIX by [email protected]
179179
import sys, os
180-
if sys.platform == 'freebsd2':
180+
if sys.platform in ('netbsd1', 'freebsd2', 'freebsd3'):
181181
flock = struct.pack('lxxxxlxxxxlhh', \
182182
l_start, l_len, os.getpid(), l_type, l_whence)
183183
elif sys.platform in ['aix3', 'aix4']:
@@ -190,7 +190,7 @@ def lock(self, how, *args):
190190
flock = fcntl.fcntl(self._file_.fileno(), cmd, flock)
191191

192192
if '?' in how:
193-
if sys.platform == 'freebsd2':
193+
if sys.platform in ('netbsd1', 'freebsd2', 'freebsd3'):
194194
l_start, l_len, l_pid, l_type, l_whence = \
195195
struct.unpack('lxxxxlxxxxlhh', flock)
196196
elif sys.platform in ['aix3', 'aix4']:

Lib/test/test_fcntl.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import struct
66
import fcntl
77
import FCNTL
8-
import os
8+
import os, sys
99
from test_support import verbose
1010

1111
filename = '/tmp/delete-me'
@@ -16,7 +16,12 @@
1616
if verbose:
1717
print 'Status from fnctl with O_NONBLOCK: ', rv
1818

19-
lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0)
19+
if sys.platform in ('netbsd1', 'freebsd2', 'freebsd3'):
20+
lockdata = struct.pack('lxxxxlxxxxlhh', 0, 0, 0, FCNTL.F_WRLCK, 0)
21+
elif sys.platform in ['aix3', 'aix4']:
22+
lockdata = struct.pack('hhlllii', FCNTL.F_WRLCK, 0, 0, 0, 0, 0, 0)
23+
else:
24+
lockdata = struct.pack('hhllhh', FCNTL.F_WRLCK, 0, 0, 0, 0, 0)
2025
if verbose:
2126
print 'struct.pack: ', `lockdata`
2227

0 commit comments

Comments
 (0)