Author: Matti Picus <matti.pi...@gmail.com> Branch: unicode-utf8 Changeset: r95130:fa230d2cf3b6 Date: 2018-09-16 21:23 +0300 http://bitbucket.org/pypy/pypy/changeset/fa230d2cf3b6/
Log: merge default into branch diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ Welcome to PyPy! -PyPy is an interperter that implements the Python programming language, based +PyPy is an interpreter that implements the Python programming language, based on the RPython compiler framework for dynamic language implementations. The home page for the interpreter is: @@ -15,29 +15,29 @@ http://doc.pypy.org/ -More documentation about the RPython framework can be found here +More documentation about the RPython framework can be found here: - http://rpython.readthedocs.io + http://rpython.readthedocs.io/ -The source for the documentation is in the pypy/doc directory +The source for the documentation is in the pypy/doc directory. + Using PyPy instead of CPython -============================= +----------------------------- -Please read the information at http://pypy.org to find the correct way to +Please read the information at http://pypy.org/ to find the correct way to download and use PyPy as an alternative to CPython. + Building -======== +-------- Building PyPy is not the recommended way to obtain the PyPy alternative python interpreter. It is time-consuming and requires significant computing resources. -More information can be found here +More information can be found here: http://doc.pypy.org/en/latest/build.html Enjoy and send us feedback! the pypy-dev team <pypy-...@python.org> - - diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py --- a/pypy/module/_cffi_backend/ctypeptr.py +++ b/pypy/module/_cffi_backend/ctypeptr.py @@ -311,9 +311,7 @@ if isinstance(self.ctitem, ctypeprim.W_CTypePrimitiveBool): self._must_be_string_of_zero_or_one(value) keepalives[i] = value - buf, buf_flag = rffi.get_nonmovingbuffer_final_null(value) - rffi.cast(rffi.CCHARPP, cdata)[0] = buf - return ord(buf_flag) # 4, 5 or 6 + return misc.write_string_as_charp(cdata, value) # if (space.isinstance_w(w_init, space.w_list) or space.isinstance_w(w_init, space.w_tuple)): diff --git a/pypy/module/_cffi_backend/misc.py b/pypy/module/_cffi_backend/misc.py --- a/pypy/module/_cffi_backend/misc.py +++ b/pypy/module/_cffi_backend/misc.py @@ -3,7 +3,7 @@ from pypy.interpreter.error import OperationError, oefmt from rpython.rlib import jit -from rpython.rlib.objectmodel import specialize +from rpython.rlib.objectmodel import specialize, we_are_translated from rpython.rlib.rarithmetic import r_uint, r_ulonglong from rpython.rlib.unroll import unrolling_iterable from rpython.rtyper.lltypesystem import lltype, llmemory, rffi @@ -102,6 +102,12 @@ def write_raw_longdouble_data(target, source): rffi.cast(rffi.LONGDOUBLEP, target)[0] = source +@jit.dont_look_inside # lets get_nonmovingbuffer_final_null be inlined +def write_string_as_charp(target, string): + buf, buf_flag = rffi.get_nonmovingbuffer_final_null(string) + rffi.cast(rffi.CCHARPP, target)[0] = buf + return ord(buf_flag) # 4, 5 or 6 + # ____________________________________________________________ sprintf_longdouble = rffi.llexternal( @@ -128,7 +134,7 @@ # (possibly) convert and cast a Python object to a long long. # This version accepts a Python int too, and does convertions from # other types of objects. It refuses floats. - if space.is_w(space.type(w_ob), space.w_int): # shortcut + if space.isinstance_w(w_ob, space.w_int): # shortcut return space.int_w(w_ob) try: bigint = space.bigint_w(w_ob, allow_conversion=False) @@ -145,27 +151,18 @@ def as_long(space, w_ob): # Same as as_long_long(), but returning an int instead. - if space.is_w(space.type(w_ob), space.w_int): # shortcut + if space.isinstance_w(w_ob, space.w_int): # shortcut return space.int_w(w_ob) - try: - bigint = space.bigint_w(w_ob, allow_conversion=False) - except OperationError as e: - if not e.match(space, space.w_TypeError): - raise - if _is_a_float(space, w_ob): - raise - bigint = space.bigint_w(space.int(w_ob), allow_conversion=False) - try: - return bigint.toint() - except OverflowError: - raise OperationError(space.w_OverflowError, space.newtext(ovf_msg)) + if _is_a_float(space, w_ob): + space.bigint_w(w_ob, allow_conversion=False) # raise the right error + return space.int_w(space.int(w_ob)) def as_unsigned_long_long(space, w_ob, strict): # (possibly) convert and cast a Python object to an unsigned long long. # This accepts a Python int too, and does convertions from other types of # objects. If 'strict', complains with OverflowError; if 'not strict', # mask the result and round floats. - if space.is_w(space.type(w_ob), space.w_int): # shortcut + if space.isinstance_w(w_ob, space.w_int): # shortcut value = space.int_w(w_ob) if strict and value < 0: raise OperationError(space.w_OverflowError, space.newtext(neg_msg)) @@ -190,8 +187,10 @@ def as_unsigned_long(space, w_ob, strict): # same as as_unsigned_long_long(), but returning just an Unsigned - if space.is_w(space.type(w_ob), space.w_int): # shortcut + if space.isinstance_w(w_ob, space.w_int): # shortcut value = space.int_w(w_ob) + if not we_are_translated(): + value = getattr(value, 'constant', value) # for NonConstant if strict and value < 0: raise OperationError(space.w_OverflowError, space.newtext(neg_msg)) return r_uint(value) 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 @@ -334,8 +334,18 @@ max = (1 << (8*size-1)) - 1 assert newp(pp, min)[0] == min assert newp(pp, max)[0] == max + py.test.raises(OverflowError, newp, pp, min - 2 ** 32) + py.test.raises(OverflowError, newp, pp, min - 2 ** 64) + py.test.raises(OverflowError, newp, pp, max + 2 ** 32) + py.test.raises(OverflowError, newp, pp, max + 2 ** 64) py.test.raises(OverflowError, newp, pp, min - 1) py.test.raises(OverflowError, newp, pp, max + 1) + py.test.raises(OverflowError, newp, pp, min - 1 - 2 ** 32) + py.test.raises(OverflowError, newp, pp, min - 1 - 2 ** 64) + py.test.raises(OverflowError, newp, pp, max + 1) + py.test.raises(OverflowError, newp, pp, max + 1 + 2 ** 32) + py.test.raises(OverflowError, newp, pp, max + 1 + 2 ** 64) + py.test.raises(TypeError, newp, pp, 1.0) for name in ['char', 'short', 'int', 'long', 'long long']: p = new_primitive_type('unsigned ' + name) pp = new_pointer_type(p) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit