[pypy-commit] pypy release-2.2.x: Update to cffi/8a16eff7850c.
arigo
noreply at buildbot.pypy.org
Tue Nov 12 13:56:18 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: release-2.2.x
Changeset: r67974:662e4114634e
Date: 2013-11-12 13:55 +0100
http://bitbucket.org/pypy/pypy/changeset/662e4114634e/
Log: Update to cffi/8a16eff7850c.
diff --git a/pypy/module/_cffi_backend/__init__.py b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -1,3 +1,4 @@
+import sys
from pypy.interpreter.mixedmodule import MixedModule
from rpython.rlib import rdynload
@@ -43,6 +44,8 @@
'FFI_DEFAULT_ABI': 'ctypefunc._get_abi(space, "FFI_DEFAULT_ABI")',
'FFI_CDECL': 'ctypefunc._get_abi(space,"FFI_DEFAULT_ABI")',#win32 name
}
+ if sys.platform == 'win32':
+ interpleveldefs['getwinerror'] = 'cerrno.getwinerror'
for _name in ["RTLD_LAZY", "RTLD_NOW", "RTLD_GLOBAL", "RTLD_LOCAL",
"RTLD_NODELETE", "RTLD_NOLOAD", "RTLD_DEEPBIND"]:
diff --git a/pypy/module/_cffi_backend/cerrno.py b/pypy/module/_cffi_backend/cerrno.py
--- a/pypy/module/_cffi_backend/cerrno.py
+++ b/pypy/module/_cffi_backend/cerrno.py
@@ -39,3 +39,14 @@
def set_errno(space, errno):
ec = get_errno_container(space)
ec._cffi_saved_errno = errno
+
+# ____________________________________________________________
+
+ at unwrap_spec(code=int)
+def getwinerror(space, code=-1):
+ from rpython.rlib.rwin32 import FormatError
+ if code == -1:
+ ec = get_errno_container(space)
+ code = ec._cffi_saved_LastError
+ message = FormatError(code)
+ return space.newtuple([space.wrap(code), space.wrap(message)])
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -2687,6 +2687,16 @@
#
res = GetLastError()
assert res == 42
+ #
+ SetLastError(2)
+ code, message = getwinerror()
+ assert code == 2
+ assert message == "The system cannot find the file specified"
+ #
+ code, message = getwinerror(1155)
+ assert code == 1155
+ assert message == ("No application is associated with the "
+ "specified file for this operation")
def test_nonstandard_integer_types():
for typename in ['int8_t', 'uint8_t', 'int16_t', 'uint16_t', 'int32_t',
More information about the pypy-commit
mailing list