Bug in py32win manual for file_locking for Python 2.4

P

Pekka Niiranen

Hi,

I tried to lock file in w2k using example
directly from pyWin32 manual:

#--------------.... win32con.GENERIC_READ|win32con.GENERIC_WRITE, \
.... win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE, \
.... secur_att, \
.... win32con.OPEN_ALWAYS, \
.... win32con.FILE_ATTRIBUTE_NORMAL , 0 )win32file.LockFileEx(hfile,win32con.LOCKFILE_EXCLUSIVE_LOCK,0,highbits,ov)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
OverflowError: long int too large to convert to int
#-------------

However, using
highbits=0x7fff0000 # equals hex(sys.maxint)
gives no errors, but does locking work if
highbits are not exactly 0xffff0000?

Does anybody have example of locking the whole directory
in one go without looping thru its files?

-pekka-
 
N

Nick Coghlan

Pekka said:
However, using
highbits=0x7fff0000 # equals hex(sys.maxint)
gives no errors, but does locking work if
highbits are not exactly 0xffff0000?

Try using highbits=-0x7fff0000 as your mask. That should set the MSB without
tripping over the sys.maxint limit.

Cheers,
Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top