Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r77987:531b9dea9776 Date: 2015-06-09 12:09 +0200 http://bitbucket.org/pypy/pypy/changeset/531b9dea9776/
Log: Update to cffi 1.1.2 diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.1.1 +Version: 1.1.2 Summary: Foreign Function Interface for Python calling C code. Home-page: http://cffi.readthedocs.org Author: Armin Rigo, Maciej Fijalkowski diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -4,8 +4,8 @@ from .api import FFI, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.1.1" -__version_info__ = (1, 1, 1) +__version__ = "1.1.2" +__version_info__ = (1, 1, 2) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/gc_weakref.py b/lib_pypy/cffi/gc_weakref.py --- a/lib_pypy/cffi/gc_weakref.py +++ b/lib_pypy/cffi/gc_weakref.py @@ -4,25 +4,21 @@ class GcWeakrefs(object): def __init__(self, ffi): self.ffi = ffi - self.data = [] - self.freelist = None + self.data = {} + self.nextindex = 0 def build(self, cdata, destructor): # make a new cdata of the same type as the original one new_cdata = self.ffi.cast(self.ffi._backend.typeof(cdata), cdata) # def remove(key): - assert self.data[index] is key - self.data[index] = self.freelist - self.freelist = index + # careful, this function is not protected by any lock + old_key = self.data.pop(index) + assert old_key is key destructor(cdata) # key = ref(new_cdata, remove) - index = self.freelist - if index is None: - index = len(self.data) - self.data.append(key) - else: - self.freelist = self.data[index] - self.data[index] = key + index = self.nextindex + self.nextindex = index + 1 # we're protected by the lock here + self.data[index] = key return new_cdata 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 @@ -2,7 +2,7 @@ from pypy.interpreter.mixedmodule import MixedModule from rpython.rlib import rdynload -VERSION = "1.1.1" +VERSION = "1.1.2" class Module(MixedModule): 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 @@ -3335,4 +3335,4 @@ def test_version(): # this test is here mostly for PyPy - assert __version__ == "1.1.1" + assert __version__ == "1.1.2" diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_zintegration.py @@ -1,6 +1,5 @@ # Generated by pypy/tool/import_cffi.py import py, os, sys, shutil -import imp import subprocess from pypy.module.test_lib_pypy.cffi_tests.udir import udir @@ -16,28 +15,12 @@ except OSError as e: py.test.skip("Cannot execute virtualenv: %s" % (e,)) - try: - deepcopy = os.symlink - except: - import shutil, errno - def deepcopy(src, dst): - try: - shutil.copytree(src, dst) - except OSError as e: - if e.errno in (errno.ENOTDIR, errno.EINVAL): - shutil.copy(src, dst) - else: - print('got errno') - print(e.errno) - print('not') - print(errno.ENOTDIR) - raise - site_packages = None for dirpath, dirnames, filenames in os.walk(str(tmpdir)): if os.path.basename(dirpath) == 'site-packages': site_packages = dirpath break + paths = "" if site_packages: try: from cffi import _pycparser @@ -50,15 +33,22 @@ pass else: modules += ('ply',) # needed for older versions of pycparser + paths = [] for module in modules: - target = imp.find_module(module)[1] - deepcopy(target, os.path.join(site_packages, - os.path.basename(target))) - return tmpdir + target = __import__(module, None, None, []) + src = os.path.abspath(target.__file__) + for end in ['__init__.pyc', '__init__.pyo', '__init__.py']: + if src.lower().endswith(end): + src = src[:-len(end)-1] + break + paths.append(os.path.dirname(src)) + paths = os.pathsep.join(paths) + return tmpdir, paths SNIPPET_DIR = py.path.local(__file__).join('..', 'snippets') -def really_run_setup_and_program(dirname, venv_dir, python_snippet): +def really_run_setup_and_program(dirname, venv_dir_and_paths, python_snippet): + venv_dir, paths = venv_dir_and_paths def remove(dir): dir = str(SNIPPET_DIR.join(dirname, dir)) shutil.rmtree(dir, ignore_errors=True) @@ -76,9 +66,11 @@ else: bindir = 'bin' vp = str(venv_dir.join(bindir).join('python')) - subprocess.check_call((vp, 'setup.py', 'clean')) - subprocess.check_call((vp, 'setup.py', 'install')) - subprocess.check_call((vp, str(python_f))) + env = os.environ.copy() + env['PYTHONPATH'] = paths + subprocess.check_call((vp, 'setup.py', 'clean'), env=env) + subprocess.check_call((vp, 'setup.py', 'install'), env=env) + subprocess.check_call((vp, str(python_f)), env=env) finally: os.chdir(olddir) diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_ffi_obj.py b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_ffi_obj.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_ffi_obj.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_ffi_obj.py @@ -160,9 +160,10 @@ "struct never_heard_of_s\n" " ^") e = py.test.raises(ffi.error, ffi.cast, "\t\n\x01\x1f~\x7f\x80\xff", 0) + marks = "?" if sys.version_info < (3,) else "??" assert str(e.value) == ("identifier expected\n" - " ??~???\n" - " ^") + " ??~?%s%s\n" + " ^" % (marks, marks)) e = py.test.raises(ffi.error, ffi.cast, "X" * 600, 0) assert str(e.value) == ("undefined type name") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit