Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.5 Changeset: r87911:bc30265a8f9a Date: 2016-10-22 19:15 +0100 http://bitbucket.org/pypy/pypy/changeset/bc30265a8f9a/
Log: hg merge default diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst --- a/pypy/doc/faq.rst +++ b/pypy/doc/faq.rst @@ -397,3 +397,13 @@ in auto-generated C code, and at least some knowledge about the various components involved, from PyPy's own RPython source code to the GC and possibly the JIT. + + +Why doesn't PyPy move to GitHub, Gitlab, ...? +---------------------------------------------- + +We've been quite happy with bitbucket.org. Moving version control systems and +hosting is a lot of hard work: On the one hand, PyPy's mercurial history is +long and gnarly. On the other hand, all our infrastructure (buildbots, +benchmarking, etc) would have to be adapted. So unless somebody steps up and +volunteers to do all that work, it will likely not happen. diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py --- a/pypy/module/array/test/test_array.py +++ b/pypy/module/array/test/test_array.py @@ -2,7 +2,18 @@ import pytest -class BaseArrayTests: +class AppTestArray(object): + spaceconfig = {'usemodules': ['array', 'struct', 'binascii']} + + def setup_class(cls): + cls.w_array = cls.space.appexec([], """(): + import array + return array.array + """) + cls.w_tempfile = cls.space.wrap( + str(pytest.ensuretemp('array').join('tmpfile'))) + cls.w_maxint = cls.space.wrap(sys.maxint) + def test_ctor(self): assert len(self.array('i')) == 0 @@ -173,13 +184,6 @@ raises(ValueError, a.frombytes, a) def test_fromfile(self): - - ## class myfile(object): - ## def __init__(self, c, s): - ## self.c = c - ## self.s = s - ## def read(self,n): - ## return self.c*min(n,self.s) def myfile(c, s): f = open(self.tempfile, 'wb') f.write(c * s) @@ -242,12 +246,12 @@ assert repr(a) == "array('b', [1, 2, 1, 2])" def test_fromunicode(self): - raises(ValueError, self.array('i').fromunicode, 'hi') + raises(ValueError, self.array('i').fromunicode, u'hi') a = self.array('u') - a.fromunicode('hi') + a.fromunicode(u'hi') assert len(a) == 2 and a[0] == 'h' and a[1] == 'i' - b = self.array('u', 'hi') + b = self.array('u', u'hi') assert len(b) == 2 and b[0] == 'h' and b[1] == 'i' def test_sequence(self): @@ -344,23 +348,6 @@ except ValueError: assert not ok - def test_reversingslice_pre26(self): - import sys - if sys.version_info >= (2, 6): - skip('arrays can handle more slice ops than lists in 2.6') - - for a in range(-4, 5): - for b in range(-4, 5): - for c in [-4, -3, -2, -1, 1, 2, 3, 4]: - lst = [1, 2, 3] - arr = self.array('i', lst) - for vals in ([4, 5], [6], []): - try: - lst[a:b:c] = vals - except ValueError: - raises(ValueError, - "arr[a:b:c]=self.array('i', vals)") - def test_toxxx(self): a = self.array('i', [1, 2, 3]) l = a.tolist() @@ -406,7 +393,7 @@ assert repr(a) == "array('b', [104, 105])" raises(ValueError, self.array('i').tounicode) - assert self.array('u', 'hello').tounicode() == 'hello' + assert self.array('u', u'hello').tounicode() == u'hello' def test_empty_tostring(self): a = self.array('l') @@ -770,17 +757,16 @@ self.height = height return self - def _index(self, xy): - x, y = xy + def _index(self, x, y): x = min(max(x, 0), self.width-1) y = min(max(y, 0), self.height-1) return y * self.width + x def __getitem__(self, i): - return array.__getitem__(self, self._index(i)) + return array.__getitem__(self, self._index(*i)) def __setitem__(self, i, val): - return array.__setitem__(self, self._index(i), val) + return array.__setitem__(self, self._index(*i), val) img = Image(5, 10, 'B') for y in range(10): @@ -846,8 +832,8 @@ assert repr(mya('i', (1, 2, 3))) == "array('i', [1, 2, 3])" def test_unicode_outofrange(self): - a = self.array('u', '\x01\u263a\x00\ufeff') - b = self.array('u', '\x01\u263a\x00\ufeff') + a = self.array('u', u'\x01\u263a\x00\ufeff') + b = self.array('u', u'\x01\u263a\x00\ufeff') b.byteswap() assert a != b @@ -962,34 +948,6 @@ assert a == b assert self.array('u', bytearray(a.tobytes())) == a - def test_repr(self): - s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234' - a = self.array('u', s) - assert repr(a) == "array('u', {!r})".format(s) - assert eval(repr(a), {'array': self.array}) == a - -class DontTestCPythonsOwnArray(BaseArrayTests): - def setup_class(cls): - import array - cls.array = array.array - import struct - cls.struct = struct - cls.tempfile = str(pytest.ensuretemp('array').join('tmpfile')) - cls.maxint = sys.maxint - - -class AppTestArray(BaseArrayTests): - spaceconfig = {'usemodules': ['array', 'struct', 'binascii']} - - def setup_class(cls): - cls.w_array = cls.space.appexec([], """(): - import array - return array.array - """) - cls.w_tempfile = cls.space.wrap( - str(pytest.ensuretemp('array').join('tmpfile'))) - cls.w_maxint = cls.space.wrap(sys.maxint) - def test_buffer_info(self): a = self.array('b', b'Hi!') bi = a.buffer_info() diff --git a/pypy/module/array/test/test_array_old.py b/pypy/module/array/test/test_array_old.py deleted file mode 100644 --- a/pypy/module/array/test/test_array_old.py +++ /dev/null @@ -1,114 +0,0 @@ -# minimal tests. See also lib-python/modified-2.4.1/test/test_array. - -import py -from py.test import raises -import struct - - -class BaseArrayTests: - # XXX very incomplete - - native_sizes = {'l': struct.calcsize('l')} - - def test_attributes(self): - a = self.array.array('u') - assert a.typecode == 'u' - assert a.itemsize == 4 - a = self.array.array('l') - assert a.typecode == 'l' - assert a.itemsize == self.native_sizes['l'] - - def test_imul(self): - a = self.array.array('i', [12, 34]) - a *= 3 - assert a.tolist() == [12, 34] * 3 - - def test_unicode(self): - a = self.array.array('u') - a.fromunicode(chr(9999)) - assert len(a) == 1 - assert a.tolist() == [chr(9999)] - - def test_pickle(self): - import sys - if sys.version_info < (2, 5): - py.test.skip("array.array not picklable before python 2.5") - import pickle - - for content in [[56, -12, 34], []]: - a = self.array.array('i', content) - a2 = pickle.loads(pickle.dumps(a)) - assert type(a2) is self.array.array - assert list(a2) == content - - def test_init_vs_new(self): - import sys - if sys.version_info < (2, 5): - py.test.skip("array.array constructor changed in 2.5") - class A(self.array.array): - def __init__(self, *args, **kwds): - self.args = args - self.kwds = kwds - - a = A('u', foo='bar') - assert a.args == ('u',) - assert a.kwds == {'foo': 'bar'} - a = A('i', list(range(10)), some=42) - assert a.args == ('i', list(range(10))) - assert a.kwds == {'some': 42} - raises(TypeError, A) - raises(TypeError, A, 42) - raises(TypeError, A, 'i', [], []) - raises(TypeError, self.array.array, 'i', [], foo='bar') - - -class DontTestCPythonsOwnArray(BaseArrayTests): - - def setup_class(cls): - import array - cls.array = array - - -## class TestArrayOnTopOfCPython(BaseArrayTests): - -## def setup_class(cls): -## from pypy.tool.lib_pypy import LIB_PYPY -## if not hasattr(struct, 'pack_into'): -## py.test.skip("requires CPython >= 2.5") -## import new -## path = LIB_PYPY.join('array.py') -## myarraymodule = new.module('array') -## execfile(str(path), myarraymodule.__dict__) -## cls.array = myarraymodule - -## def test_unicode(self): -## py.test.skip("no 'u' type code in CPython's struct module") - -## def test_pickle(self): -## py.test.skip("pickle getting confused by the hack in setup_class()") - - -class AppTestArray(BaseArrayTests): - spaceconfig = {'usemodules': ['struct', 'array', 'binascii']} - - def setup_class(cls): - """Import the array module and make it available as self.array.""" - cls.w_array = cls.space.getbuiltinmodule('array') - cls.w_native_sizes = cls.space.wrap(cls.native_sizes) - - -## class AppTestArrayWithRawFFI(AppTestArray): -## """ -## The same as the base class, but with a space that also includes the -## _rawffi module. The array module internally uses it in this case. -## """ -## spaceconfig = dict(usemodules=['struct', '_rawffi']) - -## def test_buffer_info(self): -## a = self.array.array('l', [123, 456]) -## assert a.itemsize == self.native_sizes['l'] -## address, length = a.buffer_info() -## assert length == 2 # and not 2 * self.native_sizes['l'] -## assert address != 0 -## # should check the address via some unsafe peeking, but it's -## # not easy on top of py.py _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit