Author: Armin Rigo <[email protected]>
Branch:
Changeset: r94978:a233de8fbd4b
Date: 2018-08-08 13:10 +0200
http://bitbucket.org/pypy/pypy/changeset/a233de8fbd4b/
Log: update to cffi/1dd7bdcf4993
diff --git a/lib_pypy/cffi/_cffi_errors.h b/lib_pypy/cffi/_cffi_errors.h
--- a/lib_pypy/cffi/_cffi_errors.h
+++ b/lib_pypy/cffi/_cffi_errors.h
@@ -50,7 +50,9 @@
"import sys\n"
"class FileLike:\n"
" def write(self, x):\n"
- " of.write(x)\n"
+ " try:\n"
+ " of.write(x)\n"
+ " except: pass\n"
" self.buf += x\n"
"fl = FileLike()\n"
"fl.buf = ''\n"
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
@@ -1946,3 +1946,30 @@
# only works with the Python FFI instances
ffi = FFI(backend=self.Backend())
assert ffi.sizeof("struct{int a;}") == ffi.sizeof("int")
+
+ def test_callback_large_struct(self):
+ ffi = FFI(backend=self.Backend())
+ # more than 8 bytes
+ ffi.cdef("struct foo_s { unsigned long a, b, c; };")
+ #
+ @ffi.callback("void(struct foo_s)")
+ def cb(s):
+ seen.append(ffi.typeof(s))
+ s.a += 1
+ s.b += 2
+ s.c += 3
+ seen.append(s.a)
+ seen.append(s.b)
+ seen.append(s.c)
+ #
+ s1 = ffi.new("struct foo_s *", {'a': 100, 'b': 200, 'c': 300})
+ seen = []
+ cb(s1[0])
+ assert len(seen) == 4
+ assert s1.a == 100 # unmodified
+ assert s1.b == 200
+ assert s1.c == 300
+ assert seen[0] == ffi.typeof("struct foo_s")
+ assert seen[1] == 101
+ assert seen[2] == 202
+ assert seen[3] == 303
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_zdist.py
@@ -3,6 +3,8 @@
import subprocess
import cffi
from pypy.module.test_lib_pypy.cffi_tests.udir import udir
+from shutil import rmtree
+from tempfile import mkdtemp
def chdir_to_tmp(f):
@@ -34,13 +36,20 @@
env = os.environ.copy()
# a horrible hack to prevent distutils from finding ~/.pydistutils.cfg
# (there is the --no-user-cfg option, but not in Python 2.6...)
- env['HOME'] = '/this/path/does/not/exist'
+ # NOTE: pointing $HOME to a nonexistent directory can break certain
things
+ # that look there for configuration (like ccache).
+ tmp_home = mkdtemp()
+ assert tmp_home != None, "cannot create temporary homedir"
+ env['HOME'] = tmp_home
if cwd is None:
newpath = self.rootdir
if 'PYTHONPATH' in env:
newpath += os.pathsep + env['PYTHONPATH']
env['PYTHONPATH'] = newpath
- subprocess.check_call([self.executable] + args, cwd=cwd, env=env)
+ try:
+ subprocess.check_call([self.executable] + args, cwd=cwd, env=env)
+ finally:
+ rmtree(tmp_home)
def _prepare_setuptools(self):
if hasattr(TestDist, '_setuptools_ready'):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit