[PATCH] Correct use of GetLastError in ctypes windows locking code

Martin (gzlist) gzlist at googlemail.com
Tue Jun 9 17:47:24 BST 2009


Bah, sorry, I did the classic thing of assuming the change was obvious
and not explaining it properly. GetLastError must be called
immediately after the failed operation:

# function has failed, and set last error to say, 120
self._clear_f() # calls self.f.close() which succeeds and sets last error to 0
last_err = _GetLastError() # gets last error as 0

So is reported as "Unknown locking error: 0", which is what you always
get on win98 as the code never succeeds. A locking failure on any
other version on windows would have the same problem.

On 09/06/2009, John Arbash Meinel <john at arbash-meinel.com> wrote:
>
> I don't have ctypes + python2.4 on a Win98 system. I can say that ctypes
> + python2.5 + Windows Vista does have a 'ctypes.GetLastError()' function.

That was just cosmetic.

Martin



More information about the bazaar mailing list