[pypy-commit] pypy default: Change GetLastError() to return Signed, and SetLastError() and
arigo
noreply at buildbot.pypy.org
Sun Dec 4 17:40:43 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r50127:306fca1568b4
Date: 2011-12-04 16:19 +0100
http://bitbucket.org/pypy/pypy/changeset/306fca1568b4/
Log: Change GetLastError() to return Signed, and SetLastError() and
FormatError() to take a Signed.
diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -543,6 +543,7 @@
from pypy.rlib.rwin32 import GetLastError
return space.wrap(GetLastError())
-def set_last_error(space, w_error):
+ at unwrap_spec(error='nonnegint')
+def set_last_error(space, error):
from pypy.rlib.rwin32 import SetLastError
- SetLastError(space.uint_w(w_error))
+ SetLastError(error)
diff --git a/pypy/rlib/rwin32.py b/pypy/rlib/rwin32.py
--- a/pypy/rlib/rwin32.py
+++ b/pypy/rlib/rwin32.py
@@ -98,8 +98,13 @@
INVALID_HANDLE_VALUE = rffi.cast(HANDLE, -1)
PFILETIME = rffi.CArrayPtr(FILETIME)
- GetLastError = winexternal('GetLastError', [], DWORD, threadsafe=False)
- SetLastError = winexternal('SetLastError', [DWORD], lltype.Void)
+ _GetLastError = winexternal('GetLastError', [], DWORD, threadsafe=False)
+ _SetLastError = winexternal('SetLastError', [DWORD], lltype.Void)
+
+ def GetLastError():
+ return rffi.cast(lltype.Signed, _GetLastError())
+ def SetLastError(err):
+ _SetLastError(rffi.cast(DWORD, err))
# In tests, the first call to GetLastError is always wrong, because error
# is hidden by operations in ll2ctypes. Call it now.
@@ -184,12 +189,12 @@
msglen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
None,
- code,
+ rffi.cast(DWORD, code),
DEFAULT_LANGUAGE,
rffi.cast(rffi.CCHARP, buf),
0, None)
- if msglen <= 2 or msglen > sys.maxint:
+ if msglen <= 2: # includes the case msglen < 0
return fake_FormatError(code)
# FormatMessage always appends \r\n.
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -1773,7 +1773,7 @@
@registering(rwin32.FormatError)
def register_rwin32_FormatError(self):
- return extdef([rwin32.DWORD], str,
+ return extdef([lltype.Signed], str,
"rwin32_FormatError",
llimpl=rwin32.llimpl_FormatError,
ooimpl=rwin32.fake_FormatError)
More information about the pypy-commit
mailing list