[pypy-commit] buildbot default: add a dockerfile to run a centos6-based x64 buildslave
Author: Matti Picus Branch: Changeset: r1097:709f8fb564ac Date: 2019-10-31 07:12 +0200 http://bitbucket.org/pypy/buildbot/changeset/709f8fb564ac/ Log:add a dockerfile to run a centos6-based x64 buildslave diff --git a/README_BUILDSLAVE b/README_BUILDSLAVE --- a/README_BUILDSLAVE +++ b/README_BUILDSLAVE @@ -1,7 +1,13 @@ How to setup a buildslave for PyPy == -The required setup is:: +There are three documented ways to run a PyPy buildslave: + +- "bare metal" on the host machine, described below +- in a chroot, setting up the chroot is described in `README-CHROOT` +- via docker on a centos6-based image, see docker/Dockerfile + +In all cases the required setup is:: - hg - "python" should run a cpython 2.6-2.7 that will run the test suites. - virtualenv that will use the "python" from above diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,46 @@ +# build with something like this, where +# -t is the name of the image +# -f is this file +# the . is a random directory +# docker build -t buildslave -f docker/Dockerfile . +# +# To create the buildslave configuration, call +# docker run --rm -v:/build_dir \ +#-eSLAVENAME= -ePASSWORD= buildslave +# Then you can examine the /buildbot.tac file. +# +# To run the buildslave (after the stage above succeeds) you no longer need the +# SLAVENAME and PASSWORD. The slave will run non-deamonized, which will appear +# to "hang" the console running the slave. To stop the slave, simply CTRL-C or +# kill the process. +# +# To enter the buildslave image +# docker run -it -v:/build_dir> buildslave /bin/bash + +FROM centos:centos6 + +RUN yum -y update +RUN yum install -y wget bzip2-devel zlib-devel glibc-devel libX11-devel \ + libXt-devel patch expat-devel libXft-devel openssl-devel tk-devel gdbm-devel \ + perl xz-devel libffi-devel ncurses-devel sqlite-devel +RUN yum install -y centos-release-scl + +RUN wget https://github.com/squeaky-pl/centos-devtools/releases/download/8.2-s1/gcc-8.2.0-binutils-2.32-x86_64.tar.bz2 -O - | tar -C / -xj +RUN wget https://bitbucket.org/squeaky/portable-pypy/downloads/pypy-7.0.0-linux_x86_64-portable.tar.bz2 -O - | tar -C /opt -xj +RUN ln -s /opt/pypy-7.0.0-linux_x86_64-portable/bin/pypy /usr/local/bin/pypy + +RUN yum install -y python27 python27-python-virtualenv + +#yuck +ENV LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64 +RUN /opt/rh/python27/root/usr/bin/python -mvirtualenv /python27_virt +ENV PATH=/python27_virt/bin:$PATH +ENV PATH=/opt/devtools-8.2/bin:$PATH +RUN pip install --upgrade pip setuptools +RUN pip install buildbot-slave pytest hypothesis cffi vmprof mercurial + +CMD if [ -e /build_dir/buildbot.tac ]; then \ +buildslave start --nodaemon /build_dir; \ + else \ +buildslave create-slave /build_dir buildbot.pypy.org:10407 $SLAVENAME $PASSWORD; \ + fi ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix uses of raises()
Author: Ronan Lamy Branch: Changeset: r97897:ef97a01d2e01 Date: 2019-10-30 21:15 + http://bitbucket.org/pypy/pypy/changeset/ef97a01d2e01/ Log:Fix uses of raises() diff --git a/pypy/interpreter/test/test_function.py b/pypy/interpreter/test/test_function.py --- a/pypy/interpreter/test/test_function.py +++ b/pypy/interpreter/test/test_function.py @@ -76,7 +76,8 @@ return x return f f = g(42) -raises(TypeError, FuncType, f.func_code, f.func_globals, 'f2', None, None) +with raises(TypeError): +FuncType(f.func_code, f.func_globals, 'f2', None, None) def test_write_code(self): def f(): @@ -134,8 +135,10 @@ assert res[1] == 22 assert res[2] == 333 -raises(TypeError, func) -raises(TypeError, func, 1, 2, 3, 4) +with raises(TypeError): +func() +with raises(TypeError): +func(1, 2, 3, 4) def test_simple_varargs(self): def func(arg1, *args): @@ -162,7 +165,8 @@ def test_kwargs_sets_wrong_positional_raises(self): def func(arg1): pass -raises(TypeError, func, arg2=23) +with raises(TypeError): +func(arg2=23) def test_kwargs_sets_positional(self): def func(arg1): @@ -180,8 +184,8 @@ def test_kwargs_sets_positional_twice(self): def func(arg1, **kw): return arg1, kw -raises( -TypeError, func, 42, {'arg1': 23}) +with raises(TypeError): +func(42, {'arg1': 23}) def test_kwargs_nondict_mapping(self): class Mapping: @@ -194,9 +198,10 @@ res = func(23, **Mapping()) assert res[0] == 23 assert res[1] == {'a': 'a', 'b': 'b'} -error = raises(TypeError, lambda: func(42, **[])) -assert error.value.message == ('argument after ** must be a mapping, ' - 'not list') +with raises(TypeError) as excinfo: +func(42, **[]) +assert excinfo.value.message == ( +'argument after ** must be a mapping, not list') def test_default_arg(self): def func(arg1,arg2=42): @@ -215,12 +220,14 @@ def test_defaults_keyword_override_but_leaves_empty_positional(self): def func(arg1,arg2=42): return arg1, arg2 -raises(TypeError, func, arg2=23) +with raises(TypeError): +func(arg2=23) def test_kwargs_disallows_same_name_twice(self): def func(arg1, **kw): return arg1, kw -raises(TypeError, func, 42, **{'arg1': 23}) +with raises(TypeError): +func(42, **{'arg1': 23}) def test_kwargs_bound_blind(self): class A(object): @@ -269,15 +276,21 @@ def test_call_builtin(self): s = 'hello' -raises(TypeError, len) +with raises(TypeError): +len() assert len(s) == 5 -raises(TypeError, len, s, s) -raises(TypeError, len, s, s, s) +with raises(TypeError): +len(s, s) +with raises(TypeError): +len(s, s, s) assert len(*[s]) == 5 assert len(s, *[]) == 5 -raises(TypeError, len, some_unknown_keyword=s) -raises(TypeError, len, s, some_unknown_keyword=s) -raises(TypeError, len, s, s, some_unknown_keyword=s) +with raises(TypeError): +len(some_unknown_keyword=s) +with raises(TypeError): +len(s, some_unknown_keyword=s) +with raises(TypeError): +len(s, s, some_unknown_keyword=s) def test_call_error_message(self): try: @@ -310,8 +323,10 @@ # cannot subclass 'function' or 'builtin_function' def f(): pass -raises(TypeError, type, 'Foo', (type(f),), {}) -raises(TypeError, type, 'Foo', (type(len),), {}) +with raises(TypeError): +type('Foo', (type(f),), {}) +with raises(TypeError): +type('Foo', (type(len),), {}) def test_lambda_docstring(self): # Like CPython, (lambda:"foo") has a docstring of "foo". @@ -324,7 +339,8 @@ f = lambda: 42 # not sure what it should raise, since CPython doesn't have setstate # on function types -raises(ValueError, type(f).__setstate__, f, (1, 2, 3)) +with raises(ValueError): +type(f).__setstate__(f, (1, 2, 3)) class AppTestMethod: def test_simple_call(self): @@ -471,14 +487,13 @@ assert A.foo(A(), 42) == (42,) assert A.foo(B(), 42) == (42,) -raises(TypeError, A.foo, 5) -raises(TypeError, B.foo, C()) -try: +with raises(TypeError): +A.foo(5) +with raises(TypeError): +B.foo(C()) +with raises(TypeError): class Fun: __metaclass__ = A.foo -assert 0 # should have raised -
[pypy-commit] pypy default: issue 2970: add ncursesw to _minimal_curses
Author: Matti Picus Branch: Changeset: r97894:bba4a466169d Date: 2019-10-30 21:21 +0200 http://bitbucket.org/pypy/pypy/changeset/bba4a466169d/ Log:issue 2970: add ncursesw to _minimal_curses diff --git a/pypy/module/_minimal_curses/fficurses.py b/pypy/module/_minimal_curses/fficurses.py --- a/pypy/module/_minimal_curses/fficurses.py +++ b/pypy/module/_minimal_curses/fficurses.py @@ -14,6 +14,8 @@ yield ExternalCompilationInfo(includes=['curses.h', 'term.h']) yield ExternalCompilationInfo(includes=['curses.h', 'term.h'], include_dirs=['/usr/include/ncurses']) +yield ExternalCompilationInfo(includes=['curses.h', 'term.h'], + include_dirs=['/usr/include/ncursesw']) yield ExternalCompilationInfo(includes=['ncurses/curses.h', 'ncurses/term.h']) @@ -23,6 +25,8 @@ yield ExternalCompilationInfo(libraries=['ncurses']) yield ExternalCompilationInfo(libraries=['ncurses'], library_dirs=['/usr/lib64']) +yield ExternalCompilationInfo(libraries=['ncursesw'], + library_dirs=['/usr/lib64']) def try_tools(): try: @@ -30,6 +34,10 @@ except Exception: pass try: +yield ExternalCompilationInfo.from_pkg_config("ncursesw") +except Exception: +pass +try: yield ExternalCompilationInfo.from_config_tool("ncurses5-config") except Exception: pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.6: issue 2971: update from upstream package, should fix failing tests
Author: Matti Picus Branch: py3.6 Changeset: r97893:97cf5afa67c7 Date: 2019-10-30 20:00 +0200 http://bitbucket.org/pypy/pypy/changeset/97cf5afa67c7/ Log:issue 2971: update from upstream package, should fix failing tests diff --git a/extra_tests/test_pyrepl/infrastructure.py b/extra_tests/test_pyrepl/infrastructure.py --- a/extra_tests/test_pyrepl/infrastructure.py +++ b/extra_tests/test_pyrepl/infrastructure.py @@ -59,6 +59,11 @@ return Event(*ev) +def getpending(self): +"""Nothing pending, but do not return None here.""" +return Event('key', '', b'') + + class BaseTestReader(Reader): def get_prompt(self, lineno, cursor_on_line): diff --git a/extra_tests/test_pyrepl/test_readline.py b/extra_tests/test_pyrepl/test_readline.py --- a/extra_tests/test_pyrepl/test_readline.py +++ b/extra_tests/test_pyrepl/test_readline.py @@ -15,8 +15,7 @@ os.write(master, b'input\n') with sane_term(): -result = readline_wrapper.get_reader().readline() -#result = readline_wrapper.raw_input('prompt:') +result = readline_wrapper.raw_input('prompt:') assert result == 'input' # A bytes string on python2, a unicode string on python3. assert isinstance(result, str) diff --git a/extra_tests/test_pyrepl/test_wishes.py b/extra_tests/test_pyrepl/test_wishes.py --- a/extra_tests/test_pyrepl/test_wishes.py +++ b/extra_tests/test_pyrepl/test_wishes.py @@ -27,5 +27,5 @@ read_spec([ (('digit-arg', '3'), ['']), (('quoted-insert', None), ['']), -(('self-insert', '\033'), ['^[^[^[']), +(('key', '\033'), ['^[^[^[']), (('accept', None),None)]) diff --git a/lib_pypy/pyrepl/commands.py b/lib_pypy/pyrepl/commands.py --- a/lib_pypy/pyrepl/commands.py +++ b/lib_pypy/pyrepl/commands.py @@ -369,8 +369,12 @@ class qIHelp(Command): def do(self): +from .reader import disp_str + r = self.reader -r.insert((self.event + r.console.getpending().data) * r.get_arg()) +pending = r.console.getpending().data +disp = disp_str((self.event + pending).encode())[0] +r.insert(disp * r.get_arg()) r.pop_input_trans() from pyrepl import input diff --git a/lib_pypy/pyrepl/readline.py b/lib_pypy/pyrepl/readline.py --- a/lib_pypy/pyrepl/readline.py +++ b/lib_pypy/pyrepl/readline.py @@ -259,7 +259,7 @@ except _error: return _old_raw_input(prompt) reader.ps1 = prompt -return reader.readline(reader, startup_hook=self.startup_hook) +return reader.readline(returns_unicode=True, startup_hook=self.startup_hook) def multiline_input(self, more_lines, ps1, ps2, returns_unicode=False): """Read an input on possibly multiple lines, asking for more ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.6: issue 2970: add ncursesw to _minimal_curses
Author: Matti Picus Branch: py3.6 Changeset: r97892:140497be04d3 Date: 2019-10-30 18:52 +0200 http://bitbucket.org/pypy/pypy/changeset/140497be04d3/ Log:issue 2970: add ncursesw to _minimal_curses diff --git a/lib_pypy/pyrepl/_minimal_curses.py b/lib_pypy/pyrepl/_minimal_curses.py --- a/lib_pypy/pyrepl/_minimal_curses.py +++ b/lib_pypy/pyrepl/_minimal_curses.py @@ -16,7 +16,7 @@ def _find_clib(): -trylibs = ['ncurses', 'curses'] +trylibs = ['ncursesw', 'ncurses', 'curses'] for lib in trylibs: path = ctypes.util.find_library(lib) diff --git a/pypy/module/_minimal_curses/fficurses.py b/pypy/module/_minimal_curses/fficurses.py --- a/pypy/module/_minimal_curses/fficurses.py +++ b/pypy/module/_minimal_curses/fficurses.py @@ -14,6 +14,8 @@ yield ExternalCompilationInfo(includes=['curses.h', 'term.h']) yield ExternalCompilationInfo(includes=['curses.h', 'term.h'], include_dirs=['/usr/include/ncurses']) +yield ExternalCompilationInfo(includes=['curses.h', 'term.h'], + include_dirs=['/usr/include/ncursesw']) yield ExternalCompilationInfo(includes=['ncurses/curses.h', 'ncurses/term.h']) @@ -23,6 +25,8 @@ yield ExternalCompilationInfo(libraries=['ncurses']) yield ExternalCompilationInfo(libraries=['ncurses'], library_dirs=['/usr/lib64']) +yield ExternalCompilationInfo(libraries=['ncursesw'], + library_dirs=['/usr/lib64']) def try_tools(): try: @@ -30,6 +34,10 @@ except Exception: pass try: +yield ExternalCompilationInfo.from_pkg_config("ncursesw") +except Exception: +pass +try: yield ExternalCompilationInfo.from_config_tool("ncurses5-config") except Exception: pass ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.6: PyUnicode_New()
Author: Armin Rigo Branch: py3.6 Changeset: r97891:699e6250c3cc Date: 2019-10-30 10:32 +0100 http://bitbucket.org/pypy/pypy/changeset/699e6250c3cc/ Log:PyUnicode_New() diff --git a/pypy/module/cpyext/test/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py --- a/pypy/module/cpyext/test/test_unicodeobject.py +++ b/pypy/module/cpyext/test/test_unicodeobject.py @@ -391,6 +391,38 @@ s = module.asutf32(u) assert s == u.encode('utf-32') +def test_UnicodeNew(self): +module = self.import_extension('unicodenew', [ +("make", "METH_VARARGS", +""" +long length = PyLong_AsLong(PyTuple_GetItem(args, 0)); +long unichr = PyLong_AsLong(PyTuple_GetItem(args, 1)); + +PyObject *retval = PyUnicode_New(length, (Py_UCS4)unichr); +if (unichr <= 255) { +Py_UCS1 *retbuf = PyUnicode_1BYTE_DATA(retval); +for (long i = 0; i < length; i++) +retbuf[i] = unichr; +} +else if (unichr <= 65535) { +Py_UCS2 *retbuf = PyUnicode_2BYTE_DATA(retval); +for (long i = 0; i < length; i++) +retbuf[i] = unichr; +} +else { +Py_UCS4 *retbuf = PyUnicode_4BYTE_DATA(retval); +for (long i = 0; i < length; i++) +retbuf[i] = unichr; +} +return retval; +"""), +]) +assert module.make(0, 32) == u'' +assert module.make(1, 32) == u' ' +assert module.make(5, 255) == u'\xff' * 5 +assert module.make(3, 0x1234) == u'\u1234' * 3 +assert module.make(7, 0x12345) == u'\U00012345' * 7 + class TestUnicode(BaseApiTest): def test_unicodeobject(self, space): diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -8,12 +8,13 @@ from pypy.interpreter.unicodehelper import ( wcharpsize2utf8, str_decode_utf_16_helper, str_decode_utf_32_helper, unicode_encode_decimal, utf8_encode_utf_16_helper, BYTEORDER, -utf8_encode_utf_32_helper) +utf8_encode_utf_32_helper, str_decode_latin_1) from pypy.objspace.std.unicodeobject import unicodedb from pypy.module.cpyext.api import ( CANNOT_FAIL, Py_ssize_t, build_type_checkers, cpython_api, bootstrap_function, CONST_STRING, INTP_real, -CONST_WSTRING, Py_CLEANUP_SUPPORTED, slot_function, cts, parse_dir) +CONST_WSTRING, Py_CLEANUP_SUPPORTED, slot_function, cts, parse_dir, +PyTypeObjectPtr) from pypy.module.cpyext.pyerrors import PyErr_BadArgument from pypy.module.cpyext.pyobject import ( PyObject, PyObjectP, decref, make_ref, from_ref, track_reference, @@ -22,6 +23,7 @@ from pypy.module._codecs.interp_codecs import ( CodecState, latin_1_decode, utf_16_decode, utf_32_decode) from pypy.objspace.std import unicodeobject +from rpython.rlib.debug import fatalerror import sys ## See comment in bytesobject.py. @@ -91,8 +93,31 @@ Creates the unicode in the interpreter. The PyUnicodeObject buffer must not be modified after this call. Can raise in wcharpsize2utf8 """ -lgt = get_wsize(py_obj) -s_utf8 = wcharpsize2utf8(space, get_wbuffer(py_obj), lgt) +if not get_wbuffer(py_obj): +if not get_compact(py_obj): +fatalerror( +"internal cpyext error: realizing a non-compact unicode " +"object with wbuffer == null") +data = get_data(py_obj) +size = get_len(py_obj) +kind = get_kind(py_obj) +value = rffi.charpsize2str(data, size * kind) +if kind == _1BYTE_KIND: +s_utf8, lgt, _ = str_decode_latin_1(value, 'strict', True, None) +elif kind == _2BYTE_KIND: +decoded = str_decode_utf_16_helper(value, 'strict', True, None, + byteorder=BYTEORDER) +s_utf8, lgt = decoded[:2] +elif kind == _4BYTE_KIND: +decoded = str_decode_utf_32_helper(value, 'strict', True, None, + byteorder=BYTEORDER) +s_utf8, lgt = decoded[:2] +else: +assert False +else: +lgt = get_wsize(py_obj) +s_utf8 = wcharpsize2utf8(space, get_wbuffer(py_obj), lgt) + w_type = from_ref(space, rffi.cast(PyObject, py_obj.c_ob_type)) w_obj = space.allocate_instance(unicodeobject.W_UnicodeObject, w_type) w_obj.__init__(s_utf8, lgt) @@ -191,6 +216,15 @@ py_obj.c_wstr_length = value def get_data(py_obj): +if get_compact(py_obj): +if get_ascii(py_obj): +PyASCIIObject = cts.gettype('PyASCIIObject') +struct_size = rffi.sizeof(PyASCIIObject) +else: +
[pypy-commit] pypy default: Don't allocate a small list here
Author: Armin Rigo Branch: Changeset: r97890:195ceabd426e Date: 2019-10-30 10:31 +0100 http://bitbucket.org/pypy/pypy/changeset/195ceabd426e/ Log:Don't allocate a small list here diff --git a/pypy/interpreter/unicodehelper.py b/pypy/interpreter/unicodehelper.py --- a/pypy/interpreter/unicodehelper.py +++ b/pypy/interpreter/unicodehelper.py @@ -1184,9 +1184,9 @@ size = len(s) if BYTEORDER == 'little': -iorder = [0, 1, 2, 3] +iorder0, iorder1, iorder2, iorder3 = 0, 1, 2, 3 else: -iorder = [3, 2, 1, 0] +iorder0, iorder1, iorder2, iorder3 = 3, 2, 1, 0 # Check for BOM marks (U+FEFF) in the input and adjust current # byte order setting accordingly. In native mode, the leading BOM @@ -1196,8 +1196,8 @@ if byteorder == 'native': if size >= 4: bom = intmask( -(ord(s[iorder[3]]) << 24) | (ord(s[iorder[2]]) << 16) | -(ord(s[iorder[1]]) << 8) | ord(s[iorder[0]])) +(ord(s[iorder3]) << 24) | (ord(s[iorder2]) << 16) | +(ord(s[iorder1]) << 8) | ord(s[iorder0])) if BYTEORDER == 'little': if bom == BOM32_DIRECT: pos += 4 @@ -1220,10 +1220,10 @@ return '', 0, 0, bo if bo == -1: # force little endian -iorder = [0, 1, 2, 3] +iorder0, iorder1, iorder2, iorder3 = 0, 1, 2, 3 elif bo == 1: # force big endian -iorder = [3, 2, 1, 0] +iorder0, iorder1, iorder2, iorder3 = 3, 2, 1, 0 result = StringBuilder(size // 4) @@ -1239,8 +1239,8 @@ if len(s) - pos < 4: break continue -ch = ((ord(s[pos + iorder[3]]) << 24) | (ord(s[pos + iorder[2]]) << 16) | - (ord(s[pos + iorder[1]]) << 8) | ord(s[pos + iorder[0]])) +ch = ((ord(s[pos + iorder3]) << 24) | (ord(s[pos + iorder2]) << 16) | + (ord(s[pos + iorder1]) << 8) | ord(s[pos + iorder0])) if not allow_surrogates and 0xD800 <= ch <= 0xDFFF: r, pos = errorhandler(errors, public_encoding_name, "code point in surrogate code point " ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit