Author: Maciej Fijalkowski <fij...@gmail.com> Branch: Changeset: r76323:48dadfa8f69e Date: 2015-03-11 12:31 +0200 http://bitbucket.org/pypy/pypy/changeset/48dadfa8f69e/
Log: merge diff --git a/lib_pypy/cffi.egg-info b/lib_pypy/cffi.egg-info --- a/lib_pypy/cffi.egg-info +++ b/lib_pypy/cffi.egg-info @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: cffi -Version: 0.9.0 +Version: 0.9.1 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__ = "0.9.0" -__version_info__ = (0, 9, 0) +__version__ = "0.9.1" +__version_info__ = (0, 9, 1) # 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/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,13 +2,15 @@ from pypy.interpreter.mixedmodule import MixedModule from rpython.rlib import rdynload +VERSION = "0.9.1" + class Module(MixedModule): appleveldefs = { } interpleveldefs = { - '__version__': 'space.wrap("0.9.0")', + '__version__': 'space.wrap("%s")' % VERSION, 'load_library': 'libraryobj.load_library', 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 @@ -3249,4 +3249,4 @@ def test_version(): # this test is here mostly for PyPy - assert __version__ == "0.9.0" + assert __version__ == "0.9.1" diff --git a/pypy/module/_cffi_backend/test/test_file.py b/pypy/module/_cffi_backend/test/test_file.py --- a/pypy/module/_cffi_backend/test/test_file.py +++ b/pypy/module/_cffi_backend/test/test_file.py @@ -15,3 +15,15 @@ "Update test/_backend_test_c.py by copying it from " "https://bitbucket.org/cffi/cffi/raw/default/c/test_c.py " "and killing the import lines at the start") + +def test_egginfo_version(): + from pypy.module._cffi_backend import VERSION + line = "Version: %s\n" % VERSION + eggfile = py.path.local(__file__).join('..', '..', '..', '..', '..', + 'lib_pypy', 'cffi.egg-info') + assert line in eggfile.readlines() + +def test_app_version(): + from pypy.module import _cffi_backend + from lib_pypy import cffi + assert _cffi_backend.VERSION == cffi.__version__ diff --git a/pypy/module/_random/interp_random.py b/pypy/module/_random/interp_random.py --- a/pypy/module/_random/interp_random.py +++ b/pypy/module/_random/interp_random.py @@ -4,7 +4,7 @@ from pypy.interpreter.typedef import TypeDef from pypy.interpreter.gateway import interp2app, unwrap_spec from pypy.interpreter.baseobjspace import W_Root -from rpython.rlib.rarithmetic import r_uint, intmask +from rpython.rlib.rarithmetic import r_uint, intmask, widen from rpython.rlib import rbigint, rrandom, rstring @@ -54,8 +54,8 @@ def getstate(self, space): state = [None] * (rrandom.N + 1) for i in range(rrandom.N): - state[i] = space.newint(intmask(self._rnd.state[i])) - state[rrandom.N] = space.newint(self._rnd.index) + state[i] = space.wrap(widen(self._rnd.state[i])) + state[rrandom.N] = space.newlong(self._rnd.index) return space.newtuple(state) def setstate(self, space, w_state): diff --git a/pypy/module/_random/test/test_random.py b/pypy/module/_random/test/test_random.py --- a/pypy/module/_random/test/test_random.py +++ b/pypy/module/_random/test/test_random.py @@ -41,6 +41,17 @@ # does not crash rnd1.setstate((-1, ) * 624 + (0, )) + def test_state_repr(self): + # since app-level jumpahead salts with repr(state), + # it is important the repr is consistent with cpython + import _random + rnd = _random.Random() + rnd.seed(1234) + state = rnd.getstate() + s = repr(state) + assert len(s) == 7956 + assert s.count('L') == 625 + def test_seed(self): import _random, sys rnd = _random.Random() diff --git a/pypy/module/_ssl/__init__.py b/pypy/module/_ssl/__init__.py --- a/pypy/module/_ssl/__init__.py +++ b/pypy/module/_ssl/__init__.py @@ -51,6 +51,11 @@ super(Module, cls).buildloaders() + def setup_after_space_initialization(self): + """NOT_RPYTHON""" + from pypy.module._ssl.interp_ssl import PWINFO_STORAGE + PWINFO_STORAGE.clear() + def startup(self, space): from rpython.rlib.ropenssl import init_ssl init_ssl() diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py --- a/pypy/module/micronumpy/ndarray.py +++ b/pypy/module/micronumpy/ndarray.py @@ -1462,6 +1462,7 @@ imag = GetSetProperty(W_NDimArray.descr_get_imag, W_NDimArray.descr_set_imag), conj = interp2app(W_NDimArray.descr_conj), + conjugate = interp2app(W_NDimArray.descr_conj), argsort = interp2app(W_NDimArray.descr_argsort), sort = interp2app(W_NDimArray.descr_sort), diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py --- a/pypy/module/micronumpy/test/test_complex.py +++ b/pypy/module/micronumpy/test/test_complex.py @@ -382,6 +382,7 @@ assert np.conjugate(1+2j) == 1-2j eye2 = np.array([[1, 0], [0, 1]]) + assert (eye2.conjugate() == eye2).all() x = eye2 + 1j * eye2 for a, b in zip(np.conjugate(x), np.array([[ 1.-1.j, 0.-0.j], [ 0.-0.j, 1.-1.j]])): assert a[0] == b[0] diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py b/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py --- a/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py +++ b/pypy/module/test_lib_pypy/cffi_tests/test_zdistutils.py @@ -165,7 +165,8 @@ assert lib.sin(12.3) == math.sin(12.3) v = ffi.verifier ext = v.get_extension() - assert 'distutils.extension.Extension' in str(ext.__class__) + assert 'distutils.extension.Extension' in str(ext.__class__) or \ + 'setuptools.extension.Extension' in str(ext.__class__) assert ext.sources == [maybe_relative_path(v.sourcefilename)] assert ext.name == v.get_module_name() assert ext.define_macros == [('TEST_EXTENSION_OBJECT', '1')] @@ -194,7 +195,8 @@ assert lib.test1eoes(7.0) == 42.0 v = ffi.verifier ext = v.get_extension() - assert 'distutils.extension.Extension' in str(ext.__class__) + assert 'distutils.extension.Extension' in str(ext.__class__) or \ + 'setuptools.extension.Extension' in str(ext.__class__) assert ext.sources == [maybe_relative_path(v.sourcefilename), extra_source] assert ext.name == v.get_module_name() diff --git a/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py b/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py --- a/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py +++ b/pypy/module/test_lib_pypy/cffi_tests/test_zintegration.py @@ -4,6 +4,9 @@ import subprocess from pypy.module.test_lib_pypy.cffi_tests.udir import udir +if sys.platform == 'win32': + py.test.skip('snippets do not run on win32') + def create_venv(name): tmpdir = udir.join(name) try: @@ -13,6 +16,20 @@ 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',e.errno,'not',errno.ENOTDIR + raise + site_packages = None for dirpath, dirnames, filenames in os.walk(str(tmpdir)): if os.path.basename(dirpath) == 'site-packages': @@ -32,7 +49,7 @@ modules += ('ply',) # needed for older versions of pycparser for module in modules: target = imp.find_module(module)[1] - os.symlink(target, os.path.join(site_packages, + deepcopy(target, os.path.join(site_packages, os.path.basename(target))) return tmpdir @@ -51,7 +68,11 @@ python_f.write(py.code.Source(python_snippet)) try: os.chdir(str(SNIPPET_DIR.join(dirname))) - vp = str(venv_dir.join('bin/python')) + if os.name == 'nt': + bindir = 'Scripts' + 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))) diff --git a/pypy/objspace/fake/checkmodule.py b/pypy/objspace/fake/checkmodule.py --- a/pypy/objspace/fake/checkmodule.py +++ b/pypy/objspace/fake/checkmodule.py @@ -10,6 +10,7 @@ mod = __import__('pypy.module.%s' % modname, None, None, ['__doc__']) # force computation and record what we wrap module = mod.Module(space, W_Root()) + module.setup_after_space_initialization() module.startup(space) for name in module.loaders: seeobj_w.append(module._load_lazily(space, name)) diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py --- a/rpython/annotator/test/test_annrpython.py +++ b/rpython/annotator/test/test_annrpython.py @@ -4326,13 +4326,6 @@ assert isinstance(s, annmodel.SomeString) assert not s.can_be_none() - def test_nonnulify(self): - s = annmodel.SomeString(can_be_None=True).nonnulify() - assert s.can_be_None is True - assert s.no_nul is True - s = annmodel.SomeChar().nonnulify() - assert s.no_nul is True - def g(n): return [0, 1, 2, n] diff --git a/rpython/annotator/test/test_model.py b/rpython/annotator/test/test_model.py --- a/rpython/annotator/test/test_model.py +++ b/rpython/annotator/test/test_model.py @@ -117,3 +117,11 @@ assert s_int != SomeInteger() assert not_const(s_int) == SomeInteger() assert not_const(s_None) == s_None + + +def test_nonnulify(): + s = SomeString(can_be_None=True).nonnulify() + assert s.can_be_None is True + assert s.no_nul is True + s = SomeChar().nonnulify() + assert s.no_nul is True diff --git a/rpython/doc/jit/virtualizable.rst b/rpython/doc/jit/virtualizable.rst --- a/rpython/doc/jit/virtualizable.rst +++ b/rpython/doc/jit/virtualizable.rst @@ -44,8 +44,14 @@ virtualizable arrays that can be very confusing. Those will usually end up with a compile-time error (as opposed to strange behavior). The rules are: +* A virtualizable array must be a fixed-size list. After it is + initialized (e.g. in ``Frame.__init__``) you cannot resize it at all. + You cannot assign a different list to the field, or even pass around the + list. You can only access ``frame.array[index]`` directly. + * Each array access must be with a known positive index that cannot raise - an ``IndexError``. Using ``no = jit.hint(no, promote=True)`` might be useful + an ``IndexError``. + Using ``index = jit.hint(index, promote=True)`` might be useful to get a constant-number access. This is only safe if the index is actually constant or changing rarely within the context of the user's code. diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py --- a/rpython/jit/codewriter/jtransform.py +++ b/rpython/jit/codewriter/jtransform.py @@ -143,13 +143,16 @@ return for v in list: if v in self.vable_array_vars: + vars = self.vable_array_vars[v] + (v_base, arrayfielddescr, arraydescr) = vars raise AssertionError( "A virtualizable array is passed around; it should\n" "only be used immediately after being read. Note\n" "that a possible cause is indexing with an index not\n" "known non-negative, or catching IndexError, or\n" "not inlining at all (for tests: use listops=True).\n" - "Occurred in: %r" % self.graph) + "This is about: %r\n" + "Occurred in: %r" % (arrayfielddescr, self.graph)) # extra explanation: with the way things are organized in # rpython/rlist.py, the ll_getitem becomes a function call # that is typically meant to be inlined by the JIT, but diff --git a/rpython/jit/codewriter/test/test_flatten.py b/rpython/jit/codewriter/test/test_flatten.py --- a/rpython/jit/codewriter/test/test_flatten.py +++ b/rpython/jit/codewriter/test/test_flatten.py @@ -999,6 +999,7 @@ e = py.test.raises(AssertionError, self.encoding_test, f, [], "!", transform=True) assert str(e.value).startswith("A virtualizable array is passed aroun") + assert "<Descr>" in str(e.value) def test_vable_attribute_list_copied_around(self): class F: @@ -1014,6 +1015,7 @@ e = py.test.raises(AssertionError, self.encoding_test, f, [], "!", transform=True) assert str(e.value).startswith("A virtualizable array is passed aroun") + assert "<Descr>" in str(e.value) def check_force_cast(FROM, TO, operations, value): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit