[pypy-commit] pypy py3.5: merge default

2019-02-17 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r96038:1c54055fec69
Date: 2019-02-17 12:53 +0100
http://bitbucket.org/pypy/pypy/changeset/1c54055fec69/

Log:merge default

diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -124,6 +124,7 @@
 end = rutf8.next_codepoint_pos(w_seq._utf8, start)
 w_res = W_UnicodeObject(w_seq._utf8[start:end], 1)
 self.byteindex = end
+self.index += 1
 return w_res
 
 
diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -45,6 +45,7 @@
 w_iter = space.iter(w_uni)
 w_char1 = w_iter.descr_next(space)
 w_char2 = w_iter.descr_next(space)
+py.test.raises(OperationError, w_iter.descr_next, space)
 assert w_uni._index_storage is old_index_storage
 assert space.eq_w(w_char1, w_uni._getitem_result(space, 0))
 assert space.eq_w(w_char2, w_uni._getitem_result(space, 1))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default

2019-02-17 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r96036:c87433506699
Date: 2019-02-17 12:35 +0100
http://bitbucket.org/pypy/pypy/changeset/c87433506699/

Log:merge default

diff --git a/extra_tests/cffi_tests/cffi0/test_ownlib.py 
b/extra_tests/cffi_tests/cffi0/test_ownlib.py
--- a/extra_tests/cffi_tests/cffi0/test_ownlib.py
+++ b/extra_tests/cffi_tests/cffi0/test_ownlib.py
@@ -352,6 +352,8 @@
 def test_modify_struct_value(self):
 if self.module is None:
 py.test.skip("fix the auto-generation of the tiny test lib")
+if self.Backend is CTypesBackend:
+py.test.skip("fails with the ctypes backend on some architectures")
 ffi = FFI(backend=self.Backend())
 ffi.cdef("""
 typedef struct {
diff --git a/extra_tests/cffi_tests/embedding/thread3-test.c 
b/extra_tests/cffi_tests/embedding/thread3-test.c
--- a/extra_tests/cffi_tests/embedding/thread3-test.c
+++ b/extra_tests/cffi_tests/embedding/thread3-test.c
@@ -52,5 +52,6 @@
 assert(status == 0);
 }
 printf("done\n");
+fflush(stdout);   /* this is occasionally needed on Windows */
 return 0;
 }
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
@@ -5,8 +5,8 @@
 from .error import CDefError, FFIError, VerificationError, VerificationMissing
 from .error import PkgConfigError
 
-__version__ = "1.12.0"
-__version_info__ = (1, 12, 0)
+__version__ = "1.12.1"
+__version_info__ = (1, 12, 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/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -8,43 +8,20 @@
the same works for the other two macros.  Py_DEBUG implies them,
but not the other way around.
 
-   The implementation is messy (issue #350): on Windows, with _MSC_VER,
-   we have to define Py_LIMITED_API even before including pyconfig.h.
-   In that case, we guess what pyconfig.h will do to the macros above,
-   and check our guess after the #include.
-
-   Note that on Windows, with CPython 3.x, you need virtualenv version
-   >= 16.0.0.  Older versions don't copy PYTHON3.DLL.  As a workaround
-   you can remove the definition of Py_LIMITED_API here.
-
-   See also 'py_limited_api' in cffi/setuptools_ext.py.
+   Issue #350 is still open: on Windows, the code here causes it to link
+   with PYTHON36.DLL (for example) instead of PYTHON3.DLL.  A fix was
+   attempted in 164e526a5515 and 14ce6985e1c3, but reverted: virtualenv
+   does not make PYTHON3.DLL available, and so the "correctly" compiled
+   version would not run inside a virtualenv.  We will re-apply the fix
+   after virtualenv has been fixed for some time.  For explanation, see
+   issue #355.  For a workaround if you want PYTHON3.DLL and don't worry
+   about virtualenv, see issue #350.  See also 'py_limited_api' in
+   setuptools_ext.py.
 */
 #if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
-#  ifdef _MSC_VER
-#if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && 
!defined(Py_REF_DEBUG)
-#  define Py_LIMITED_API
-#endif
-#include 
- /* sanity-check: Py_LIMITED_API will cause crashes if any of these
-are also defined.  Normally, the Python file PC/pyconfig.h does not
-cause any of these to be defined, with the exception that _DEBUG
-causes Py_DEBUG.  Double-check that. */
-#ifdef Py_LIMITED_API
-#  if defined(Py_DEBUG)
-#error "pyconfig.h unexpectedly defines Py_DEBUG, but Py_LIMITED_API 
is set"
-#  endif
-#  if defined(Py_TRACE_REFS)
-#error "pyconfig.h unexpectedly defines Py_TRACE_REFS, but 
Py_LIMITED_API is set"
-#  endif
-#  if defined(Py_REF_DEBUG)
-#error "pyconfig.h unexpectedly defines Py_REF_DEBUG, but 
Py_LIMITED_API is set"
-#  endif
-#endif
-#  else
-#include 
-#if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
-#  define Py_LIMITED_API
-#endif
+#  include 
+#  if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
+#define Py_LIMITED_API
 #  endif
 #endif
 
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -221,7 +221,7 @@
 
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.12.0"
+   "\ncompiled with cffi version: 1.12.1"
"\n_cffi_backend module: ", f);
 modules = PyImport_GetModuleDict();
 mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/lib_pypy/cffi/setuptools_ext.py b/lib_pypy/cffi/setuptools_ext.py

[pypy-commit] pypy py3.5: merge default into branch

2019-02-15 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r96013:c27524ca09c9
Date: 2019-02-15 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/c27524ca09c9/

Log:merge default into branch

diff --git a/rpython/rlib/test/test_rutf8.py b/rpython/rlib/test/test_rutf8.py
--- a/rpython/rlib/test/test_rutf8.py
+++ b/rpython/rlib/test/test_rutf8.py
@@ -130,7 +130,7 @@
 assert (rutf8.codepoint_position_at_index(u.encode('utf8'), index, i) 
==
 len(u[:i].encode('utf8')))
 
-@given(strategies.text(average_size=140))
+@given(strategies.text())
 @example(u'x' * 64 * 5)
 @example(u'x' * (64 * 5 - 1))
 def test_codepoint_index_at_byte_position(u):
@@ -152,7 +152,7 @@
 @example([u'\ud800', u'\udc00'])
 def test_surrogate_in_utf8(unichars):
 uni = ''.join([u.encode('utf8') for u in unichars])
-result = rutf8.surrogate_in_utf8(uni) < 0
+result = rutf8.surrogate_in_utf8(uni) >= 0
 expected = any(uch for uch in unichars if u'\ud800' <= uch <= u'\udfff')
 assert result == expected
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2019-02-13 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r96006:f468bb5ec141
Date: 2019-02-13 23:18 +0200
http://bitbucket.org/pypy/pypy/changeset/f468bb5ec141/

Log:merge default into branch

diff --git a/pypy/doc/extending.rst b/pypy/doc/extending.rst
--- a/pypy/doc/extending.rst
+++ b/pypy/doc/extending.rst
@@ -45,16 +45,13 @@
 with the `CPython ctypes`_ version.  It works for large examples, such
 as pyglet.  PyPy's implementation is not strictly 100% compatible with
 CPython, but close enough for most cases.
-
-We also used to provide ``ctypes-configure`` for some API-level access.
-This is now viewed as a precursor of CFFI, which you should use instead.
 More (but older) information is available :doc:`here 
`.
 Also, ctypes' performance is not as good as CFFI's.
 
 .. _CPython ctypes: http://docs.python.org/library/ctypes.html
 
 PyPy implements ctypes as pure Python code around two built-in modules
-called ``_ffi`` and ``_rawffi``, which give a very low-level binding to
+called ``_rawffi`` and ``_rawffi.alt``, which give a very low-level binding to
 the C library libffi_.  Nowadays it is not recommended to use directly
 these two modules.
 
diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst
--- a/pypy/doc/index.rst
+++ b/pypy/doc/index.rst
@@ -103,7 +103,7 @@
 the `development mailing list`_.
 
 .. _#pypy on irc.freenode.net: irc://irc.freenode.net/pypy
-.. _here: https://botbot.me/freenode/pypy/
+.. _here: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end
 .. _Development mailing list: http://mail.python.org/mailman/listinfo/pypy-dev
 .. _Commit mailing list: http://mail.python.org/mailman/listinfo/pypy-commit
 .. _Development bug/feature tracker: https://bitbucket.org/pypy/pypy/issues
diff --git a/pypy/doc/release-v7.0.0.rst b/pypy/doc/release-v7.0.0.rst
--- a/pypy/doc/release-v7.0.0.rst
+++ b/pypy/doc/release-v7.0.0.rst
@@ -19,11 +19,12 @@
 Until we can work with downstream providers to distribute builds with PyPy, we
 have made packages for some common packages `available as wheels`_.
 
-The GC `hooks`_ , which can be used to gain more insights into its
+The `GC hooks`_ , which can be used to gain more insights into its
 performance, has been improved and it is now possible to manually manage the
 GC by using a combination of ``gc.disable`` and ``gc.collect_step``. See the
 `GC blog post`_.
 
+.. _`GC hooks`: 
http://doc.pypy.org/en/latest/gc_info.html#semi-manual-gc-management
 
 We updated the `cffi`_ module included in PyPy to version 1.12, and the
 `cppyy`_ backend to 1.4. Please use these to wrap your C and C++ code,
@@ -49,7 +50,7 @@
 
 We would also like to thank our contributors and encourage new people to join
 the project. PyPy has many layers and we need help with all of them: `PyPy`_
-and `RPython`_ documentation improvements, tweaking popular `modules`_ to run
+and `RPython`_ documentation improvements, tweaking popular modules to run
 on pypy, or general `help`_ with making RPython's JIT even better.
 
 .. _`PyPy`: index.html
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -25,6 +25,15 @@
 Improve performance of long operations where one of the operands fits into
 an int.
 
-.. branch: regalloc-playgrounds
+.. branch: regalloc-playground
 
 Improve register allocation in the JIT.
+
+.. branch: promote-unicode
+
+Implement rlib.jit.promote_unicode to complement promote_string
+
+.. branch: unicode-utf8
+
+Use utf8 internally to represent unicode, with the goal of never using 
rpython-level unicode
+
diff --git a/pypy/module/zlib/test/test_zlib.py 
b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -2,8 +2,8 @@
 Tests for the zlib module.
 """
 
+import pypy
 import py
-import pypy
 
 try:
 import zlib
@@ -15,7 +15,7 @@
 from pypy.module.zlib import interp_zlib
 from rpython.rlib import rzlib
 except ImportError:
-import py; py.test.skip("no zlib C library on this machine")
+py.test.skip("no zlib C library on this machine")
 
 
 class AppTestZlib(object):
@@ -403,6 +403,7 @@
 
 assert (d1 + from_copy) == (d1 + from_compressor)
 
+@py.test.mark.skipif(rzlib.ZLIB_VERSION == '1.2.8', reason='does not error 
check')
 def test_cannot_copy_compressor_with_stream_in_inconsistent_state(self):
 if self.runappdirect: skip("can't run with -A")
 compressor = self.zlib.compressobj()
diff --git a/rpython/jit/backend/arm/regalloc.py 
b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -305,9 +305,8 @@
 operations = cpu.gc_ll_descr.rewrite_assembler(cpu, operations,
allgcrefs)
 # compute longevity of variables
-longevity, last_real_usage = compute_vars_longevity(inputargs, 
operations)
+longevity = compute_vars_longevity

[pypy-commit] pypy py3.5: merge default

2019-02-08 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r95896:8d7a3fd5c328
Date: 2019-02-08 11:56 +0100
http://bitbucket.org/pypy/pypy/changeset/8d7a3fd5c328/

Log:merge default

diff too long, truncating to 2000 out of 2357 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -58,3 +58,6 @@
 3f6eaa010fce78cc7973bdc1dfdb95970f08fed2 release-pypy3.5-v5.10.1
 ab0b9caf307db6592905a80b8faffd69b39005b8 release-pypy2.7-v6.0.0
 fdd60ed87e941677e8ea11acf9f1819466521bf2 release-pypy3.5-v6.0.0
+9112c8071614108b1042bfef0713915107004d62 release-pypy2.7-v7.0.0
+1f86f25937b6ae6c8b25236c35228fac587678bf release-pypy3.5-v7.0.0
+dab365a465140aa79a5f3ba4db784c4af4d5c195 release-pypy3.6-v7.0.0
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -13,3 +13,9 @@
 
 The zlib module's compressobj and decompressobj now expose copy methods
 as they do on CPython.
+
+
+.. math-improvements
+
+Improve performance of long operations where one of the operands fits into
+an int.
\ No newline at end of file
diff --git a/pypy/module/zlib/test/test_zlib.py 
b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -28,6 +28,8 @@
 compression and decompression tests have a little real data to assert
 against.
 """
+cls.w_runappdirect = cls.space.wrap(cls.runappdirect)
+
 cls.w_zlib = cls.space.getbuiltinmodule('zlib')
 expanded = b'some bytes which will be compressed'
 cls.w_expanded = cls.space.newbytes(expanded)
diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -437,7 +437,7 @@
 return ix
 
 
-def _pow_ovf2long(space, iv, iw, w_modulus):
+def _pow_ovf2long(space, iv, w_iv, iw, w_iw, w_modulus):
 if space.is_none(w_modulus) and _recover_with_smalllong(space):
 from pypy.objspace.std.smalllongobject import _pow as _pow_small
 try:
@@ -446,9 +446,12 @@
 return _pow_small(space, r_longlong(iv), iw, r_longlong(0))
 except (OverflowError, ValueError):
 pass
-from pypy.objspace.std.longobject import W_LongObject
-w_iv = W_LongObject.fromint(space, iv)
-w_iw = W_LongObject.fromint(space, iw)
+from pypy.objspace.std.longobject import W_LongObject, W_AbstractLongObject
+if w_iv is None or not isinstance(w_iv, W_AbstractLongObject):
+w_iv = W_LongObject.fromint(space, iv)
+if w_iw is None or not isinstance(w_iw, W_AbstractLongObject):
+w_iw = W_LongObject.fromint(space, iw)
+
 return w_iv.descr_pow(space, w_iw, w_modulus)
 
 
@@ -456,7 +459,7 @@
 op = getattr(operator, opname, None)
 assert op or ovf2small
 
-def ovf2long(space, x, y):
+def ovf2long(space, x, w_x, y, w_y):
 """Handle overflowing to smalllong or long"""
 if _recover_with_smalllong(space):
 if ovf2small:
@@ -468,9 +471,12 @@
 b = r_longlong(y)
 return W_SmallLongObject(op(a, b))
 
-from pypy.objspace.std.longobject import W_LongObject
-w_x = W_LongObject.fromint(space, x)
-w_y = W_LongObject.fromint(space, y)
+from pypy.objspace.std.longobject import W_LongObject, 
W_AbstractLongObject
+if w_x is None or not isinstance(w_x, W_AbstractLongObject):
+w_x = W_LongObject.fromint(space, x)
+if w_y is None or not isinstance(w_y, W_AbstractLongObject):
+w_y = W_LongObject.fromint(space, y)
+
 return getattr(w_x, 'descr_' + opname)(space, w_y)
 
 return ovf2long
@@ -630,12 +636,18 @@
 # can't return NotImplemented (space.pow doesn't do full
 # ternary, i.e. w_modulus.__zpow__(self, w_exponent)), so
 # handle it ourselves
-return _pow_ovf2long(space, x, y, w_modulus)
+return _pow_ovf2long(space, x, self, y, w_exponent, w_modulus)
 
 try:
 result = _pow(space, x, y, z)
-except (OverflowError, ValueError):
-return _pow_ovf2long(space, x, y, w_modulus)
+except OverflowError:
+return _pow_ovf2long(space, x, self, y, w_exponent, w_modulus)
+except ValueError:
+# float result, so let avoid a roundtrip in rbigint.
+self = self.descr_float(space)
+w_exponent = w_exponent.descr_float(space)
+return space.pow(self, w_exponent, space.w_None)
+
 return space.newint(result)
 
 @unwrap_spec(w_modulus=WrappedDefault(None))
@@ -685,7 +697,7 @@
 try:
 z = ovfcheck(op(x, y))
 except OverflowError:
-return ovf2long(space, x, y)
+return ovf2long(space, x, self, y, w_other)
 else:
 z = op(x, y)
 

[pypy-commit] pypy py3.5: Merge default.

2019-02-06 Thread Julian Berman
Author: Julian Berman 
Branch: py3.5
Changeset: r95869:5186243836bc
Date: 2019-02-06 12:24 +0100
http://bitbucket.org/pypy/pypy/changeset/5186243836bc/

Log:Merge default.

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -5,6 +5,10 @@
 .. this is a revision shortly after release-pypy-7.0.0
 .. startrev: 481c69f7d81f
 
+.. branch: zlib-copying-redux
+
+Fix calling copy on already-flushed compressobjs.
+
 .. branch: zlib-copying
 
 The zlib module's compressobj and decompressobj now expose copy methods
diff --git a/pypy/module/zlib/interp_zlib.py b/pypy/module/zlib/interp_zlib.py
--- a/pypy/module/zlib/interp_zlib.py
+++ b/pypy/module/zlib/interp_zlib.py
@@ -154,6 +154,11 @@
 try:
 self.lock()
 try:
+if not self.stream:
+raise oefmt(
+space.w_ValueError,
+"Compressor was already flushed",
+)
 copied = rzlib.deflateCopy(self.stream)
 finally:
 self.unlock()
@@ -308,9 +313,6 @@
 try:
 self.lock()
 try:
-if not self.stream:
-raise zlib_error(space,
- "decompressor object already flushed")
 copied = rzlib.inflateCopy(self.stream)
 finally:
 self.unlock()
diff --git a/pypy/module/zlib/test/test_zlib.py 
b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -366,7 +366,8 @@
 
 assert (d1 + from_copy) == (d1 + from_decompressor)
 
-def test_unsuccessful_decompress_copy(self):
+def test_cannot_copy_decompressor_with_stream_in_inconsistent_state(self):
+if self.runappdirect: skip("can't run with -A")
 decompressor = self.zlib.decompressobj()
 self.intentionally_break_a_z_stream(zobj=decompressor)
 raises(self.zlib.error, decompressor.copy)
@@ -400,7 +401,13 @@
 
 assert (d1 + from_copy) == (d1 + from_compressor)
 
-def test_unsuccessful_compress_copy(self):
+def test_cannot_copy_compressor_with_stream_in_inconsistent_state(self):
+if self.runappdirect: skip("can't run with -A")
 compressor = self.zlib.compressobj()
 self.intentionally_break_a_z_stream(zobj=compressor)
 raises(self.zlib.error, compressor.copy)
+
+def test_cannot_copy_compressor_with_flushed_stream(self):
+compressor = self.zlib.compressobj()
+compressor.flush()
+raises(ValueError, compressor.copy)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2019-02-05 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95829:7e2f5836e315
Date: 2019-02-05 14:43 +0100
http://bitbucket.org/pypy/pypy/changeset/7e2f5836e315/

Log:merge default into py3.5

diff --git a/lib_pypy/cffi/pkgconfig.py b/lib_pypy/cffi/pkgconfig.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/cffi/pkgconfig.py
@@ -0,0 +1,121 @@
+# pkg-config, https://www.freedesktop.org/wiki/Software/pkg-config/ 
integration for cffi
+import sys, os, subprocess
+
+from .error import PkgConfigError
+
+
+def merge_flags(cfg1, cfg2):
+"""Merge values from cffi config flags cfg2 to cf1
+
+Example:
+merge_flags({"libraries": ["one"]}, {"libraries": ["two"]})
+{"libraries": ["one", "two"]}
+"""
+for key, value in cfg2.items():
+if key not in cfg1:
+cfg1[key] = value
+else:
+if not isinstance(cfg1[key], list):
+raise TypeError("cfg1[%r] should be a list of strings" % 
(key,))
+if not isinstance(value, list):
+raise TypeError("cfg2[%r] should be a list of strings" % 
(key,))
+cfg1[key].extend(value)
+return cfg1
+
+
+def call(libname, flag, encoding=sys.getfilesystemencoding()):
+"""Calls pkg-config and returns the output if found
+"""
+a = ["pkg-config", "--print-errors"]
+a.append(flag)
+a.append(libname)
+try:
+pc = subprocess.Popen(a, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
+except EnvironmentError as e:
+raise PkgConfigError("cannot run pkg-config: %s" % (str(e).strip(),))
+
+bout, berr = pc.communicate()
+if pc.returncode != 0:
+try:
+berr = berr.decode(encoding)
+except Exception:
+pass
+raise PkgConfigError(berr.strip())
+
+if sys.version_info >= (3,) and not isinstance(bout, str):   # Python 3.x
+try:
+bout = bout.decode(encoding)
+except UnicodeDecodeError:
+raise PkgConfigError("pkg-config %s %s returned bytes that cannot "
+ "be decoded with encoding %r:\n%r" %
+ (flag, libname, encoding, bout))
+
+if os.altsep != '\\' and '\\' in bout:
+raise PkgConfigError("pkg-config %s %s returned an unsupported "
+ "backslash-escaped output:\n%r" %
+ (flag, libname, bout))
+return bout
+
+
+def flags_from_pkgconfig(libs):
+r"""Return compiler line flags for FFI.set_source based on pkg-config 
output
+
+Usage
+...
+ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 
1.8.3"])
+
+If pkg-config is installed on build machine, then arguments include_dirs,
+library_dirs, libraries, define_macros, extra_compile_args and
+extra_link_args are extended with an output of pkg-config for libfoo and
+libbar.
+
+Raises PkgConfigError in case the pkg-config call fails.
+"""
+
+def get_include_dirs(string):
+return [x[2:] for x in string.split() if x.startswith("-I")]
+
+def get_library_dirs(string):
+return [x[2:] for x in string.split() if x.startswith("-L")]
+
+def get_libraries(string):
+return [x[2:] for x in string.split() if x.startswith("-l")]
+
+# convert -Dfoo=bar to list of tuples [("foo", "bar")] expected by 
distutils
+def get_macros(string):
+def _macro(x):
+x = x[2:]# drop "-D"
+if '=' in x:
+return tuple(x.split("=", 1))  # "-Dfoo=bar" => ("foo", "bar")
+else:
+return (x, None)   # "-Dfoo" => ("foo", None)
+return [_macro(x) for x in string.split() if x.startswith("-D")]
+
+def get_other_cflags(string):
+return [x for x in string.split() if not x.startswith("-I") and
+ not x.startswith("-D")]
+
+def get_other_libs(string):
+return [x for x in string.split() if not x.startswith("-L") and
+ not x.startswith("-l")]
+
+# return kwargs for given libname
+def kwargs(libname):
+fse = sys.getfilesystemencoding()
+all_cflags = call(libname, "--cflags")
+all_libs = call(libname, "--libs")
+return {
+"include_dirs": get_include_dirs(all_cflags),
+"library_dirs": get_library_dirs(all_libs),
+"libraries": get_libraries(all_libs),
+"define_macros": get_macros(all_cflags),
+"extra_compile_args": get_other_cflags(all_cflags),
+"extra_link_args": get_other_libs(all_libs),
+}
+
+# merge all arguments together
+ret = {}
+for libname in libs:
+lib_flags = kwargs(libname)
+merge_flags(ret, lib_flags)
+return ret
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -62

[pypy-commit] pypy py3.5: merge default into branch

2019-01-29 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95749:665e6fb2cccb
Date: 2019-01-30 09:26 +0200
http://bitbucket.org/pypy/pypy/changeset/665e6fb2cccb/

Log:merge default into branch

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -40,16 +40,16 @@
   Armin Rigo
   Maciej Fijalkowski
   Carl Friedrich Bolz-Tereick
+  Antonio Cuni
   Amaury Forgeot d'Arc
-  Antonio Cuni
   Matti Picus
   Samuele Pedroni
   Ronan Lamy
   Alex Gaynor
   Philip Jenvey
+  Richard Plangger
   Brian Kearns
-  Richard Plangger
-  Michael Hudson
+  Michael Hudson-Doyle
   Manuel Jacob
   David Schneider
   Holger Krekel
@@ -59,8 +59,8 @@
   Anders Chrigstrom
   Wim Lavrijsen
   Eric van Riet Paap
+  Remi Meier
   Richard Emslie
-  Remi Meier
   Alexander Schremmer
   Dan Villiom Podlaski Christiansen
   Lukas Diekmann
@@ -70,10 +70,10 @@
   Niklaus Haldimann
   Camillo Bruni
   Laura Creighton
-  Romain Guillebert
   Toon Verwaest
   Leonardo Santagada
   Seo Sanghyeon
+  Romain Guillebert
   Ronny Pfannschmidt
   Justin Peel
   Raffael Tfirst
@@ -114,12 +114,12 @@
   Squeaky
   Edd Barrett
   Timo Paulssen
+  Laurence Tratt
   Marius Gedminas
   Nicolas Truessel
   Alexandre Fayolle
   Simon Burton
   Martin Matusiak
-  Laurence Tratt
   Wenzhu Man
   Konstantin Lopuhin
   John Witulski
@@ -134,8 +134,9 @@
   Jean-Philippe St. Pierre
   Guido van Rossum
   Pavel Vinogradov
+  Stefan Beyer
+  William Leslie
   Paweł Piotr Przeradowski
-  William Leslie
   marky1991
   Ilya Osadchiy
   Tobias Oberstein
@@ -144,10 +145,10 @@
   Taavi Burns
   Adrian Kuhn
   tav
+  Stian Andreassen
   Georg Brandl
   Joannah Nanjekye
   Bert Freudenberg
-  Stian Andreassen
   Wanja Saatkamp
   Mike Blume
   Gerald Klix
@@ -163,6 +164,7 @@
   Vasily Kuznetsov
   Preston Timmons
   David Ripton
+  Pieter Zieschang
   Dusty Phillips
   Lukas Renggli
   Guenter Jantzen
@@ -176,6 +178,7 @@
   Andrew Durdin
   Ben Young
   Michael Schneider
+  Yusuke Tsutsumi
   Nicholas Riley
   Jason Chu
   Igor Trindade Oliveira
@@ -187,7 +190,6 @@
   Mariano Anaya
   anatoly techtonik
   Karl Bartel
-  Stefan Beyer
   Gabriel Lavoie
   Jared Grubb
   Alecsandru Patrascu
@@ -198,7 +200,6 @@
   Victor Stinner
   Andrews Medina
   Aaron Iles
-  p_ziesch...@yahoo.de
   Toby Watson
   Daniel Patrick
   Stuart Williams
@@ -210,6 +211,7 @@
   Mikael Schönenberg
   Stanislaw Halik
   Mihnea Saracin
+  Matt Jackson
   Berkin Ilbeyi
   Gasper Zejn
   Faye Zhao
@@ -217,12 +219,14 @@
   Anders Qvist
   Corbin Simpson
   Chirag Jadwani
+  Pauli Virtanen
   Jonathan David Riehl
   Beatrice During
   Alex Perry
   Robert Zaremba
   Alan McIntyre
   Alexander Sedov
+  David C Ellis
   Vaibhav Sood
   Reuben Cummings
   Attila Gobi
@@ -242,7 +246,6 @@
   Arjun Naik
   Aaron Gallagher
   Alexis Daboville
-  Pieter Zieschang
   Karl Ramm
   Lukas Vacek
   Omer Katz
@@ -270,12 +273,15 @@
   Catalin Gabriel Manciu
   Jacob Oscarson
   Ryan Gonzalez
+  Antoine Dupre
   Kristjan Valur Jonsson
   Lucio Torre
   Richard Lancaster
   Dan Buch
   Lene Wagner
   Tomo Cocoa
+  Miro Hrončok
+  Anthony Sottile
   David Lievens
   Neil Blakey-Milner
   Henrik Vendelbo
@@ -290,10 +296,12 @@
   Bobby Impollonia
   Roberto De Ioris
   Jeong YunWon
+  andrewjlawrence
   Christopher Armstrong
   Aaron Tubbs
   Vasantha Ganesh K
   Jason Michalski
+  Radu Ciorba
   Markus Holtermann
   Andrew Thompson
   Yusei Tahara
@@ -301,28 +309,26 @@
   Fabio Niephaus
   Akira Li
   Gustavo Niemeyer
-  Rafał Gałczyński
+  Nate Bragg
   Lucas Stadler
   roberto@goyle
+  Carl Bordum Hansen
   Matt Bogosian
   Yury V. Zaytsev
   florinpapa
   Anders Sigfridsson
-  Matt Jackson
   Nikolay Zinov
   rafalgalczyn...@gmail.com
   Joshua Gilbert
   Anna Katrina Dominguez
   Kim Jin Su
   Amber Brown
-  Miro Hrončok
-  Anthony Sottile
-  Nate Bragg
+  Andrew Stepanov
+  Rafał Gałczyński
   Ben Darnell
   Juan Francisco Cantero Hurtado
   Godefroid Chappelle
   Julian Berman
-  Michael Hudson-Doyle
   Stephan Busemann
   Dan Colish
   timo
@@ -332,6 +338,7 @@
   halgari
   Jim Baker
   Chris Lambacher
+  John Aldis
   coolbutusel...@gmail.com
   Mike Bayer
   Rodrigo Araújo
@@ -340,6 +347,7 @@
   OlivierBlanvillain
   Jonas Pfannschmidt
   Zearin
+  Johan Forsberg
   Andrey Churin
   Dan Crosta
   reub...@gmail.com
@@ -349,8 +357,9 @@
   Steve Papanik
   Eli Stevens
   Boglarka Vezer
-  gabrielg
+  gabri...@ec2-54-146-239-158.compute-1.amazonaws.com
   PavloKapyshin
+  Hervé Beraud
   Tomer Chachamu
   Christopher Groskopf
   Asmo Soinio
@@ -364,7 +373,6 @@
   Michael Chermside
   Anna Ravencroft
   remarkablerocket
-  Pauli Virtanen
   Petre Vijiac
   Berker Peksag
   Christian Muirhead
@@ -384,12 +392,13 @@
   Zooko Wilcox-O Hearn
   James Lan
   jiaaro
+  Evgenii Gorinov
   Markus Unterwaditzer
   Kristoffer Kleine
   Graham Markall
   Dan Loewenherz
   werat
-  Andrew Stepanov
+  Filip Salomonsson
   Niclas Olofsson
   Chris Pressey
   Tobias Diaz
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rs

[pypy-commit] pypy py3.5: merge default into branch

2019-01-29 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95745:9d2fa7c63b7c
Date: 2019-01-29 12:24 +0200
http://bitbucket.org/pypy/pypy/changeset/9d2fa7c63b7c/

Log:merge default into branch

diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -7,16 +7,16 @@
   Armin Rigo
   Maciej Fijalkowski
   Carl Friedrich Bolz-Tereick
+  Antonio Cuni
   Amaury Forgeot d'Arc
-  Antonio Cuni
   Matti Picus
   Samuele Pedroni
   Ronan Lamy
   Alex Gaynor
   Philip Jenvey
+  Richard Plangger
   Brian Kearns
-  Richard Plangger
-  Michael Hudson
+  Michael Hudson-Doyle
   Manuel Jacob
   David Schneider
   Holger Krekel
@@ -26,8 +26,8 @@
   Anders Chrigstrom
   Wim Lavrijsen
   Eric van Riet Paap
+  Remi Meier
   Richard Emslie
-  Remi Meier
   Alexander Schremmer
   Dan Villiom Podlaski Christiansen
   Lukas Diekmann
@@ -37,10 +37,10 @@
   Niklaus Haldimann
   Camillo Bruni
   Laura Creighton
-  Romain Guillebert
   Toon Verwaest
   Leonardo Santagada
   Seo Sanghyeon
+  Romain Guillebert
   Ronny Pfannschmidt
   Justin Peel
   Raffael Tfirst
@@ -81,12 +81,12 @@
   Squeaky
   Edd Barrett
   Timo Paulssen
+  Laurence Tratt
   Marius Gedminas
   Nicolas Truessel
   Alexandre Fayolle
   Simon Burton
   Martin Matusiak
-  Laurence Tratt
   Wenzhu Man
   Konstantin Lopuhin
   John Witulski
@@ -101,8 +101,9 @@
   Jean-Philippe St. Pierre
   Guido van Rossum
   Pavel Vinogradov
+  Stefan Beyer
+  William Leslie
   Paweł Piotr Przeradowski
-  William Leslie
   marky1991
   Ilya Osadchiy
   Tobias Oberstein
@@ -111,10 +112,10 @@
   Taavi Burns
   Adrian Kuhn
   tav
+  Stian Andreassen
   Georg Brandl
   Joannah Nanjekye
   Bert Freudenberg
-  Stian Andreassen
   Wanja Saatkamp
   Mike Blume
   Gerald Klix
@@ -130,6 +131,7 @@
   Vasily Kuznetsov
   Preston Timmons
   David Ripton
+  Pieter Zieschang
   Dusty Phillips
   Lukas Renggli
   Guenter Jantzen
@@ -143,6 +145,7 @@
   Andrew Durdin
   Ben Young
   Michael Schneider
+  Yusuke Tsutsumi
   Nicholas Riley
   Jason Chu
   Igor Trindade Oliveira
@@ -154,7 +157,6 @@
   Mariano Anaya
   anatoly techtonik
   Karl Bartel
-  Stefan Beyer
   Gabriel Lavoie
   Jared Grubb
   Alecsandru Patrascu
@@ -165,7 +167,6 @@
   Victor Stinner
   Andrews Medina
   Aaron Iles
-  p_ziesch...@yahoo.de
   Toby Watson
   Daniel Patrick
   Stuart Williams
@@ -177,6 +178,7 @@
   Mikael Schönenberg
   Stanislaw Halik
   Mihnea Saracin
+  Matt Jackson
   Berkin Ilbeyi
   Gasper Zejn
   Faye Zhao
@@ -184,12 +186,14 @@
   Anders Qvist
   Corbin Simpson
   Chirag Jadwani
+  Pauli Virtanen
   Jonathan David Riehl
   Beatrice During
   Alex Perry
   Robert Zaremba
   Alan McIntyre
   Alexander Sedov
+  David C Ellis
   Vaibhav Sood
   Reuben Cummings
   Attila Gobi
@@ -209,7 +213,6 @@
   Arjun Naik
   Aaron Gallagher
   Alexis Daboville
-  Pieter Zieschang
   Karl Ramm
   Lukas Vacek
   Omer Katz
@@ -237,12 +240,15 @@
   Catalin Gabriel Manciu
   Jacob Oscarson
   Ryan Gonzalez
+  Antoine Dupre
   Kristjan Valur Jonsson
   Lucio Torre
   Richard Lancaster
   Dan Buch
   Lene Wagner
   Tomo Cocoa
+  Miro Hrončok
+  Anthony Sottile
   David Lievens
   Neil Blakey-Milner
   Henrik Vendelbo
@@ -257,10 +263,12 @@
   Bobby Impollonia
   Roberto De Ioris
   Jeong YunWon
+  andrewjlawrence
   Christopher Armstrong
   Aaron Tubbs
   Vasantha Ganesh K
   Jason Michalski
+  Radu Ciorba
   Markus Holtermann
   Andrew Thompson
   Yusei Tahara
@@ -268,28 +276,26 @@
   Fabio Niephaus
   Akira Li
   Gustavo Niemeyer
-  Rafał Gałczyński
+  Nate Bragg
   Lucas Stadler
   roberto@goyle
+  Carl Bordum Hansen
   Matt Bogosian
   Yury V. Zaytsev
   florinpapa
   Anders Sigfridsson
-  Matt Jackson
   Nikolay Zinov
   rafalgalczyn...@gmail.com
   Joshua Gilbert
   Anna Katrina Dominguez
   Kim Jin Su
   Amber Brown
-  Miro Hrončok
-  Anthony Sottile
-  Nate Bragg
+  Andrew Stepanov
+  Rafał Gałczyński
   Ben Darnell
   Juan Francisco Cantero Hurtado
   Godefroid Chappelle
   Julian Berman
-  Michael Hudson-Doyle
   Stephan Busemann
   Dan Colish
   timo
@@ -299,6 +305,7 @@
   halgari
   Jim Baker
   Chris Lambacher
+  John Aldis
   coolbutusel...@gmail.com
   Mike Bayer
   Rodrigo Araújo
@@ -307,6 +314,7 @@
   OlivierBlanvillain
   Jonas Pfannschmidt
   Zearin
+  Johan Forsberg
   Andrey Churin
   Dan Crosta
   reub...@gmail.com
@@ -316,8 +324,9 @@
   Steve Papanik
   Eli Stevens
   Boglarka Vezer
-  gabrielg
+  gabri...@ec2-54-146-239-158.compute-1.amazonaws.com
   PavloKapyshin
+  Hervé Beraud
   Tomer Chachamu
   Christopher Groskopf
   Asmo Soinio
@@ -331,8 +340,8 @@
   Michael Chermside
   Anna Ravencroft
   remarkablerocket
-  Pauli Virtanen
   Petre Vijiac
+  hgattic
   Berker Peksag
   Christian Muirhead
   soareschen
@@ -351,12 +360,13 @@
   Zooko Wilcox-O Hearn
   James Lan
   jiaaro
+  Evgenii Gorinov
   Markus Unterwaditzer
   Kristoffer Kleine
   Graham Markall
   Dan Loewenherz
   werat
-  Andrew Stepanov
+  Filip Salomonsson
   Niclas Olofsson
   Chr

[pypy-commit] pypy py3.5: merge default into branch

2019-01-20 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95681:49aade4a2c18
Date: 2019-01-20 19:10 +0200
http://bitbucket.org/pypy/pypy/changeset/49aade4a2c18/

Log:merge default into branch

diff --git a/rpython/translator/platform/windows.py 
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -86,7 +86,7 @@
 else:
 log.msg('Running "%s" succeeded' %(vcvars,))
 except Exception as e:
-log.msg('Running "%s" failed: "%s"', (vcvars, str(e)))
+log.msg('Running "%s" failed: "%s"' % (vcvars, str(e)))
 return None
 
 stdout = stdout.replace("\r\n", "\n")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2019-01-18 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95665:ef10a3c9698b
Date: 2019-01-18 12:47 +0200
http://bitbucket.org/pypy/pypy/changeset/ef10a3c9698b/

Log:merge default into branch

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -15,11 +15,15 @@
 rsyncignore = ['_cache']
 
 try:
-from hypothesis import settings
+from hypothesis import settings, __version__
 except ImportError:
 pass
 else:
-settings.register_profile('default', deadline=None)
+if __version__[:2] < '3.6':
+s = settings(deadline=None)
+settings.register_profile('default', s)
+else:
+settings.register_profile('default', deadline=None)
 settings.load_profile('default')
 
 # PyPy's command line extra options (these are added
diff --git a/rpython/conftest.py b/rpython/conftest.py
--- a/rpython/conftest.py
+++ b/rpython/conftest.py
@@ -5,6 +5,18 @@
 
 option = None
 
+try:
+from hypothesis import settings, __version__
+except ImportError:
+pass
+else:
+if __version__[:2] < '3.6':
+s = settings(deadline=None)
+settings.register_profile('default', s)
+else:
+settings.register_profile('default', deadline=None)
+settings.load_profile('default')
+
 def braindead_deindent(self):
 """monkeypatch that wont end up doing stupid in the python tokenizer"""
 text = '\n'.join(self.lines)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2019-01-16 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95658:48303f7469f9
Date: 2019-01-17 00:28 +0200
http://bitbucket.org/pypy/pypy/changeset/48303f7469f9/

Log:merge default into branch

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -14,6 +14,14 @@
 rsyncdirs = ['.', '../lib-python', '../lib_pypy', '../demo']
 rsyncignore = ['_cache']
 
+try:
+from hypothesis import settings
+except ImportError:
+pass
+else:
+settings.register_profile('default', deadline=None)
+settings.load_profile('default')
+
 # PyPy's command line extra options (these are added
 # to py.test's standard options)
 #
diff --git a/rpython/translator/platform/windows.py 
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -9,14 +9,14 @@
 import rpython
 rpydir = str(py.path.local(rpython.__file__).join('..'))
 
-def _get_compiler_type(cc, x64_flag, ver0=None):
+def _get_compiler_type(cc, x64_flag):
 if not cc:
 cc = os.environ.get('CC','')
 if not cc:
-return MsvcPlatform(x64=x64_flag, ver0=ver0)
+return MsvcPlatform(x64=x64_flag)
 elif cc.startswith('mingw') or cc == 'gcc':
 return MingwPlatform(cc)
-return MsvcPlatform(cc=cc, x64=x64_flag, ver0=ver0)
+return MsvcPlatform(cc=cc, x64=x64_flag)
 
 def _get_vcver0():
 # try to get the compiler which served to compile python
@@ -28,17 +28,13 @@
 return vsver
 return None
 
-def Windows(cc=None, ver0=None):
-#if ver0 is None:
-#ver0 = _get_vcver0()
-return _get_compiler_type(cc, False, ver0=ver0)
+def Windows(cc=None):
+return _get_compiler_type(cc, False)
 
 def Windows_x64(cc=None, ver0=None):
 raise Exception("Win64 is not supported.  You must either build for Win32"
 " or contribute the missing support in PyPy.")
-if ver0 is None:
-ver0 = _get_vcver0()
-return _get_compiler_type(cc, True, ver0=ver0)
+return _get_compiler_type(cc, True)
 
 def _find_vcvarsall(version, x64flag):
 import rpython.tool.setuptools_msvc as msvc
@@ -50,7 +46,7 @@
 return msvc.msvc14_get_vc_env(arch)
 else:
 return msvc.msvc9_query_vcvarsall(version / 10.0, arch)
-
+
 def _get_msvc_env(vsver, x64flag):
 vcdict = None
 toolsdir = None
@@ -74,7 +70,7 @@
 # even msdn does not know which to run
 # see 
https://msdn.microsoft.com/en-us/library/1700bbwd(v=vs.90).aspx
 # which names both
-vcvars = os.path.join(toolsdir, 'vcvars32.bat') 
+vcvars = os.path.join(toolsdir, 'vcvars32.bat')
 
 import subprocess
 try:
@@ -83,12 +79,14 @@
  stderr=subprocess.PIPE)
 
 stdout, stderr = popen.communicate()
-if popen.wait() != 0:
+if popen.wait() != 0 or stdout[:5].lower() == 'error':
+log.msg('Running "%s" errored: \n\nstdout:\n%s\n\nstderr:\n%s' 
% (
+vcvars, stdout.split()[0], stderr))
 return None
-if stdout[:5].lower() == 'error':
-log.msg('Running "%s" errored: %s' %(vcvars, 
stdout.split()[0]))
-return None
-except:
+else:
+log.msg('Running "%s" succeeded' %(vcvars,))
+except Exception as e:
+log.msg('Running "%s" failed: "%s"', (vcvars, str(e)))
 return None
 
 stdout = stdout.replace("\r\n", "\n")
@@ -102,6 +100,8 @@
 for key, value in vcdict.items():
 if key.upper() in ['PATH', 'INCLUDE', 'LIB']:
 env[key.upper()] = value
+if 'PATH' not in env:
+log.msg('Did not find "PATH" in stdout\n%s' %(stdout))
 if not _find_executable('mt.exe', env['PATH']):
 # For some reason the sdk bin path is missing?
 # put it together from some other env variables that happened to exist
@@ -113,7 +113,7 @@
 log.msg('Could not find mt.exe on path=%s' % env['PATH'])
 log.msg('Running vsver %s set this env' % vsver)
 for key, value in vcdict.items():
-log.msg('%s=%s' %(key, value))
+log.msg('%s=%s' %(key, value))
 log.msg("Updated environment with vsver %d, using x64 %s" % (vsver, 
x64flag,))
 return env
 
@@ -122,7 +122,7 @@
 if ver0 in vcvers:
 vcvers.insert(0, ver0)
 errs = []
-for vsver in vcvers: 
+for vsver in vcvers:
 env = _get_msvc_env(vsver, x64flag)
 if env is not None:
 return env, vsver
@@ -189,8 +189,13 @@
 self.cc = cc
 
 # detect version of current compiler
-returncode, stdout, stderr = _run_subprocess(self.cc, [],
+try:
+returncode, stdout, stderr = _run_subprocess(self.cc, [],
  env=self.c_environ)
+ 

[pypy-commit] pypy py3.5: merge default into branch

2019-01-01 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95549:6b4ce9eb5f31
Date: 2019-01-01 10:34 +0200
http://bitbucket.org/pypy/pypy/changeset/6b4ce9eb5f31/

Log:merge default into branch

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -30,7 +30,7 @@
 DEALINGS IN THE SOFTWARE.
 
 
-PyPy Copyright holders 2003-2018
+PyPy Copyright holders 2003-2019
 
 
 Except when otherwise stated (look for LICENSE files or information at
diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -59,7 +59,7 @@
 
 # General information about the project.
 project = u'PyPy'
-copyright = u'2018, The PyPy Project'
+copyright = u'2019, The PyPy Project'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-12-23 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95520:406030262749
Date: 2018-12-23 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/406030262749/

Log:merge default into branch

diff --git a/extra_tests/cffi_tests/cffi0/test_ffi_backend.py 
b/extra_tests/cffi_tests/cffi0/test_ffi_backend.py
--- a/extra_tests/cffi_tests/cffi0/test_ffi_backend.py
+++ b/extra_tests/cffi_tests/cffi0/test_ffi_backend.py
@@ -327,6 +327,16 @@
 assert ffi.typeof(c) is ffi.typeof("char[]")
 ffi.cast("unsigned short *", c)[1] += 500
 assert list(a) == [1, 20500, 3]
+assert c == ffi.from_buffer(a, True)
+assert c == ffi.from_buffer(a, require_writable=True)
+#
+p = ffi.from_buffer(b"abcd")
+assert p[2] == b"c"
+#
+assert p == ffi.from_buffer(b"abcd", False)
+py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", 
True)
+py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
+ require_writable=True)
 
 def test_memmove(self):
 ffi = FFI()
diff --git a/extra_tests/cffi_tests/cffi1/test_ffi_obj.py 
b/extra_tests/cffi_tests/cffi1/test_ffi_obj.py
--- a/extra_tests/cffi_tests/cffi1/test_ffi_obj.py
+++ b/extra_tests/cffi_tests/cffi1/test_ffi_obj.py
@@ -244,6 +244,16 @@
 assert ffi.typeof(c) is ffi.typeof("char[]")
 ffi.cast("unsigned short *", c)[1] += 500
 assert list(a) == [1, 20500, 3]
+assert c == ffi.from_buffer(a, True)
+assert c == ffi.from_buffer(a, require_writable=True)
+#
+p = ffi.from_buffer(b"abcd")
+assert p[2] == b"c"
+#
+assert p == ffi.from_buffer(b"abcd", False)
+py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", True)
+py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
+ require_writable=True)
 
 def test_memmove():
 ffi = _cffi1_backend.FFI()
diff --git a/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py 
b/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
--- a/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
+++ b/extra_tests/cffi_tests/cffi1/test_new_ffi_1.py
@@ -1654,6 +1654,16 @@
 assert ffi.typeof(c) is ffi.typeof("char[]")
 ffi.cast("unsigned short *", c)[1] += 500
 assert list(a) == [1, 20500, 3]
+assert c == ffi.from_buffer(a, True)
+assert c == ffi.from_buffer(a, require_writable=True)
+#
+p = ffi.from_buffer(b"abcd")
+assert p[2] == b"c"
+#
+assert p == ffi.from_buffer(b"abcd", False)
+py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd", 
True)
+py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
+ require_writable=True)
 
 def test_all_primitives(self):
 assert set(PRIMITIVE_TO_INDEX) == set([
diff --git a/extra_tests/test_pyrepl/conftest.py 
b/extra_tests/test_pyrepl/conftest.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_pyrepl/conftest.py
@@ -0,0 +1,8 @@
+import sys
+
+def pytest_ignore_collect(path):
+if '__pypy__' not in sys.builtin_module_names:
+try:
+import pyrepl
+except ImportError:
+return True
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -341,7 +341,7 @@
#"""
#note that 'buffer' is a type, set on this instance by __init__
 
-def from_buffer(self, python_buffer):
+def from_buffer(self, python_buffer, require_writable=False):
 """Return a  that points to the data of the
 given Python object, which must support the buffer interface.
 Note that this is not meant to be used on the built-in types
@@ -349,7 +349,8 @@
 but only on objects containing large quantities of raw data
 in some other format, like 'array.array' or numpy arrays.
 """
-return self._backend.from_buffer(self.BCharA, python_buffer)
+return self._backend.from_buffer(self.BCharA, python_buffer,
+ require_writable)
 
 def memmove(self, dest, src, n):
 """ffi.memmove(dest, src, n) copies n bytes of memory from src to dest.
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -401,8 +401,10 @@
   
 * some functions and attributes of the ``gc`` module behave in a
   slightly different way: for example, ``gc.enable`` and
-  ``gc.disable`` are supported, but instead of enabling and disabling
-  the GC, they just enable and disable the execution of finalizers.
+  ``gc.disable`` are supported, but "enabling and disabling the GC" has
+  a different meaning in PyPy than in CPython.  These functions
+  actually enable and disable the major collections and the
+  execution 

[pypy-commit] pypy py3.5: merge default into branch

2018-12-09 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95446:1300ca1763e1
Date: 2018-12-09 11:13 +0200
http://bitbucket.org/pypy/pypy/changeset/1300ca1763e1/

Log:merge default into branch

diff --git a/extra_tests/cffi_tests/cffi1/test_parse_c_type.py 
b/extra_tests/cffi_tests/cffi1/test_parse_c_type.py
--- a/extra_tests/cffi_tests/cffi1/test_parse_c_type.py
+++ b/extra_tests/cffi_tests/cffi1/test_parse_c_type.py
@@ -4,7 +4,12 @@
 from cffi import cffi_opcode
 
 if '__pypy__' in sys.builtin_module_names:
-py.test.skip("not available on pypy", allow_module_level=True)
+try:
+# pytest >= 4.0
+py.test.skip("not available on pypy", allow_module_level=True)
+except TypeError:
+# older pytest
+py.test.skip("not available on pypy")
 
 cffi_dir = os.path.dirname(cffi_opcode.__file__)
 
diff --git a/lib_pypy/resource.py b/lib_pypy/resource.py
--- a/lib_pypy/resource.py
+++ b/lib_pypy/resource.py
@@ -4,8 +4,10 @@
 from errno import EINVAL, EPERM
 import _structseq, os
 
-try: from __pypy__ import builtinify
-except ImportError: builtinify = lambda f: f
+try:
+from __pypy__ import builtinify
+except ImportError:
+builtinify = lambda f: f
 
 
 class error(Exception):
@@ -35,7 +37,7 @@
 ru_oublock = _structseq.structseqfield(10, "block output operations")
 ru_msgsnd = _structseq.structseqfield(11,  "IPC messages sent")
 ru_msgrcv = _structseq.structseqfield(12,  "IPC messages received")
-ru_nsignals = _structseq.structseqfield(13,"signals received")
+ru_nsignals = _structseq.structseqfield(13, "signals received")
 ru_nvcsw = _structseq.structseqfield(14,   "voluntary context switches")
 ru_nivcsw = _structseq.structseqfield(15,  "involuntary context switches")
 
@@ -57,7 +59,7 @@
 ru.ru_nsignals,
 ru.ru_nvcsw,
 ru.ru_nivcsw,
-))
+))
 
 @builtinify
 def getrusage(who):
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -51,3 +51,8 @@
 .. branch: rlock-in-rpython
 
 Backport CPython fix for `thread.RLock` 
+
+
+.. branch: expose-gc-time
+
+Make GC hooks measure time in seconds (as opposed to an opaque unit).
diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -386,7 +386,7 @@
 def get_gchooks(self):
 from pypy.module.gc.hook import LowLevelGcHooks
 if self.space is None:
-raise Exception("get_gchooks must be called afeter 
get_entry_point")
+raise Exception("get_gchooks must be called after get_entry_point")
 return self.space.fromcache(LowLevelGcHooks)
 
 def get_entry_point(self, config):
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -603,8 +603,14 @@
 warnoptions = pythonwarnings.split(',') + warnoptions
 if warnoptions:
 sys.warnoptions[:] = warnoptions
-from warnings import _processoptions
-_processoptions(sys.warnoptions)
+try:
+if 'warnings' in sys.modules:
+from warnings import _processoptions
+_processoptions(sys.warnoptions)
+else:
+import warnings
+except ImportError as e:
+pass   # CPython just eats any exception here
 
 # set up the Ctrl-C => KeyboardInterrupt signal handler, if the
 # signal module is available
diff --git a/pypy/module/gc/app_referents.py b/pypy/module/gc/app_referents.py
--- a/pypy/module/gc/app_referents.py
+++ b/pypy/module/gc/app_referents.py
@@ -57,12 +57,14 @@
  'total_allocated_memory', 'jit_backend_allocated',
  'peak_memory', 'peak_allocated_memory', 
'total_arena_memory',
  'total_rawmalloced_memory', 'nursery_size',
- 'peak_arena_memory', 'peak_rawmalloced_memory'):
+ 'peak_arena_memory', 'peak_rawmalloced_memory',
+ ):
 setattr(self, item, self._format(getattr(self._s, item)))
 self.memory_used_sum = self._format(self._s.total_gc_memory + 
self._s.total_memory_pressure +
 self._s.jit_backend_used)
 self.memory_allocated_sum = 
self._format(self._s.total_allocated_memory + self._s.total_memory_pressure +
 self._s.jit_backend_allocated)
+self.total_gc_time = self._s.total_gc_time
 
 def _format(self, v):
 if v < 100:
@@ -92,6 +94,8 @@
 raw assembler allocated: %s%s
 -
 Total:   %s
+
+Total time spent in GC:  %s
 """ % (self.total_gc_memory, self.peak_memory,
   self.total_arena_memory,
   self.total_rawmalloced_memory,
@@ -106,7 +110,8 

[pypy-commit] pypy py3.5: merge default into branch

2018-11-13 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95314:3bb86a88e1d3
Date: 2018-11-13 06:10 -0800
http://bitbucket.org/pypy/pypy/changeset/3bb86a88e1d3/

Log:merge default into branch

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -179,6 +179,10 @@
 lltype.free(self._buffer, flavor='raw')
 
 def setlen(self, size, zero=False, overallocate=True):
+if self._buffer:
+delta_memory_pressure = -self.allocated * self.itemsize
+else:
+delta_memory_pressure = 0
 if size > 0:
 if size > self.allocated or size < self.allocated / 2:
 if overallocate:
@@ -191,14 +195,13 @@
 some = 0
 self.allocated = size + some
 byte_size = self.allocated * self.itemsize
+delta_memory_pressure += byte_size
 if zero:
 new_buffer = lltype.malloc(
-rffi.CCHARP.TO, byte_size, flavor='raw',
-add_memory_pressure=True, zero=True)
+rffi.CCHARP.TO, byte_size, flavor='raw', zero=True)
 else:
 new_buffer = lltype.malloc(
-rffi.CCHARP.TO, byte_size, flavor='raw',
-add_memory_pressure=True)
+rffi.CCHARP.TO, byte_size, flavor='raw')
 copy_bytes = min(size, self.len) * self.itemsize
 rffi.c_memcpy(rffi.cast(rffi.VOIDP, new_buffer),
   rffi.cast(rffi.VOIDP, self._buffer),
@@ -215,6 +218,11 @@
 lltype.free(self._buffer, flavor='raw')
 self._buffer = new_buffer
 self.len = size
+# adds the difference between the old and the new raw-malloced
+# size.  If setlen() is called a lot on the same array object,
+# it is important to take into account the fact that we also do
+# lltype.free() above.
+rgc.add_memory_pressure(delta_memory_pressure)
 
 def _fromiterable(self, w_seq):
 # used by fromsequence().
@@ -259,8 +267,10 @@
 return None
 oldbuffer = self._buffer
 self._buffer = lltype.malloc(rffi.CCHARP.TO,
-(self.len - (j - i)) * self.itemsize, flavor='raw',
-add_memory_pressure=True)
+(self.len - (j - i)) * self.itemsize, flavor='raw')
+# Issue #2913: don't pass add_memory_pressure here, otherwise
+# memory pressure grows but actual raw memory usage doesn't---we
+# are freeing the old buffer at the end of this function.
 if i:
 rffi.c_memcpy(
 rffi.cast(rffi.VOIDP, self._buffer),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-11-12 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95302:2a37ce3c7d2f
Date: 2018-11-12 09:22 -0800
http://bitbucket.org/pypy/pypy/changeset/2a37ce3c7d2f/

Log:merge default into py3.5

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
@@ -684,6 +684,8 @@
 with raises_w(space, TypeError):
 PyUnicode_FromEncodedObject(
 space, space.wrap(u_text), null_charp, None)
+assert space.unicode_w(PyUnicode_FromEncodedObject(
+space, space.wrap(s_text), null_charp, None)) == u_text
 rffi.free_charp(b_text)
 
 def test_mbcs(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
@@ -486,10 +486,14 @@
 in the unicode() built-in function.  The codec to be used is looked up
 using the Python codec registry.  Return NULL if an exception was raised by
 the codec."""
+return _pyunicode_decode(space, rffi.charpsize2str(s, size),
+ encoding, errors)
+
+def _pyunicode_decode(space, s, encoding, errors):
 if not encoding:
 # This tracks CPython 2.7, in CPython 3.4 'utf-8' is hardcoded instead
 encoding = PyUnicode_GetDefaultEncoding(space)
-w_str = space.newbytes(rffi.charpsize2str(s, size))
+w_str = space.newbytes(s)
 w_encoding = space.newtext(rffi.charp2str(encoding))
 if errors:
 w_errors = space.newtext(rffi.charp2str(errors))
@@ -525,28 +529,12 @@
 
 All other objects, including Unicode objects, cause a TypeError to be
 set."""
-if not encoding:
+if space.isinstance_w(w_obj, space.w_unicode):
 raise oefmt(space.w_TypeError, "decoding Unicode is not supported")
-w_encoding = space.newtext(rffi.charp2str(encoding))
-if errors:
-w_errors = space.newtext(rffi.charp2str(errors))
-else:
-w_errors = None
-
-# - unicode is disallowed
-# - raise TypeError for non-string types
-if space.isinstance_w(w_obj, space.w_unicode):
-w_meth = None
-else:
-try:
-w_meth = space.getattr(w_obj, space.newtext('decode'))
-except OperationError as e:
-if not e.match(space, space.w_AttributeError):
-raise
-w_meth = None
-if w_meth is None:
-raise oefmt(space.w_TypeError, "decoding Unicode is not supported")
-return space.call_function(w_meth, w_encoding, w_errors)
+if space.isinstance_w(w_obj, space.w_bytearray):   # Python 2.x specific
+raise oefmt(space.w_TypeError, "decoding bytearray is not supported")
+s = space.bufferstr_w(w_obj)
+return _pyunicode_decode(space, s, encoding, errors)
 
 
 @cpython_api([PyObject, PyObjectP], rffi.INT_real, error=0)
diff --git a/pypy/module/posix/test/test_posix2.py 
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -227,9 +227,9 @@
 def test_pickle(self):
 import pickle, os
 st = self.posix.stat(os.curdir)
-print(type(st).__module__)
+# print(type(st).__module__)
 s = pickle.dumps(st)
-print(repr(s))
+# print(repr(s))
 new = pickle.loads(s)
 assert new == st
 assert type(new) is type(st)
@@ -573,6 +573,12 @@
 res = fp.read()
 assert res == '1\n'
 
+if sys.platform == "win32":
+# using startfile in app_startfile creates global state
+test_popen.dont_track_allocations = True
+test_popen_with.dont_track_allocations = True
+test_popen_child_fds.dont_track_allocations = True
+
 if hasattr(__import__(os.name), '_getfullpathname'):
 def test__getfullpathname(self):
 # nt specific
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -236,8 +236,8 @@
 #endif
 #include 
 #include 
+#include 
 
-RPY_EXPORTED
 char *_pypy_init_home(void)
 {
 HMODULE hModule = 0;
@@ -273,7 +273,6 @@
 #include 
 #include 
 
-RPY_EXPORTED
 char *_pypy_init_home(void)
 {
 Dl_info info;
@@ -291,11 +290,27 @@
 }
 """
 
+_source_code += """
+inline
+void _pypy_init_free(char *p)
+{
+free(p);
+}
+"""
+
+if we_are_translated():
+   post_include_bits = []
+else:
+# for tests 
+post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);',
+   'RPY_EXPORTED void _pypy_init_free(char*);',
+  ]
+
 _eci = ExternalCompilationInfo(separate_module_sources=[_source_code],
-post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);'])
+   post_include_bits=post_include_bits)
 _eci = _eci.merge(rdynload.eci)
 
 pypy_in

[pypy-commit] pypy py3.5: merge default into branch

2018-11-11 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95294:27c903e0884f
Date: 2018-11-04 22:55 -0500
http://bitbucket.org/pypy/pypy/changeset/27c903e0884f/

Log:merge default into branch

diff --git a/rpython/translator/platform/windows.py 
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -85,6 +85,9 @@
 stdout, stderr = popen.communicate()
 if popen.wait() != 0:
 return None
+if stdout[:5].lower() == 'error':
+log.msg('Running "%s" errored: %s' %(vcvars, 
stdout.split()[0]))
+return None
 except:
 return None
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5, ignoring backported thread lock

2018-10-27 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95258:c5417c0faf2d
Date: 2018-10-28 08:48 +0200
http://bitbucket.org/pypy/pypy/changeset/c5417c0faf2d/

Log:merge default into py3.5, ignoring backported thread lock

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -39,3 +39,15 @@
 
 .. branch: fix-readme-typo
 
+.. branch: avoid_shell_injection_in_shutil
+
+Backport CPython fix for possible shell injection issue in `distutils.spawn`,
+https://bugs.python.org/issue34540
+
+.. branch: cffi_dlopen_unicode
+
+Enable use of unicode file names in `dlopen`
+
+.. branch: rlock-in-rpython
+
+Backport CPython fix for `thread.RLock` 
diff --git a/pypy/module/cpyext/test/test_misc.py 
b/pypy/module/cpyext/test/test_misc.py
--- a/pypy/module/cpyext/test/test_misc.py
+++ b/pypy/module/cpyext/test/test_misc.py
@@ -16,7 +16,7 @@
 '''),
 ], prologue='''
 static long my_flag = 0;
-static int my_callback(void) { my_flag++; }
+static int my_callback(void) { return ++my_flag; }
 ''')
 
 try:
diff --git a/pypy/module/pwd/interp_pwd.py b/pypy/module/pwd/interp_pwd.py
--- a/pypy/module/pwd/interp_pwd.py
+++ b/pypy/module/pwd/interp_pwd.py
@@ -37,7 +37,8 @@
 passwd_p = lltype.Ptr(config['passwd'])
 
 def external(name, args, result, **kwargs):
-return rffi.llexternal(name, args, result, compilation_info=eci, **kwargs)
+return rffi.llexternal(name, args, result, compilation_info=eci,
+   releasegil=False, **kwargs)
 
 c_getpwuid = external("getpwuid", [uid_t], passwd_p)
 c_getpwnam = external("getpwnam", [rffi.CCHARP], passwd_p)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-10-12 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95209:16a9478214da
Date: 2018-10-12 15:39 +0300
http://bitbucket.org/pypy/pypy/changeset/16a9478214da/

Log:merge default into branch

diff --git a/testrunner/lib_python_tests.py b/testrunner/lib_python_tests.py
--- a/testrunner/lib_python_tests.py
+++ b/testrunner/lib_python_tests.py
@@ -21,6 +21,7 @@
  pypyopt,
  "--timeout=3600",
  "-rs",
+ "--duration=10",
  "--resultlog=cpython.log", "lib-python",
  ] + sys.argv[1:],
 cwd=rootdir)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-10-10 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95199:d52c3dff08d6
Date: 2018-10-10 12:07 +0300
http://bitbucket.org/pypy/pypy/changeset/d52c3dff08d6/

Log:merge default into branch

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1543,7 +1543,6 @@
 
 if sys.platform == 'win32':
 get_pythonapi_source = '''
-#include 
 RPY_EXTERN
 HANDLE pypy_get_pythonapi_handle() {
 MEMORY_BASIC_INFORMATION  mi;
@@ -1557,7 +1556,7 @@
 }
 '''
 separate_module_sources.append(get_pythonapi_source)
-kwds['post_include_bits'] = [
+kwds['post_include_bits'] = ['#include ',
 'RPY_EXTERN HANDLE pypy_get_pythonapi_handle();',
 ]
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-10-09 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95197:fadba769e9bf
Date: 2018-10-09 17:36 +0300
http://bitbucket.org/pypy/pypy/changeset/fadba769e9bf/

Log:merge default into branch

diff --git a/pypy/module/_cffi_backend/embedding.py 
b/pypy/module/_cffi_backend/embedding.py
--- a/pypy/module/_cffi_backend/embedding.py
+++ b/pypy/module/_cffi_backend/embedding.py
@@ -95,7 +95,9 @@
 if os.name == 'nt':
 
 do_includes = r"""
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501
+#endif
 #include 
 
 static void _cffi_init(void);
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1557,6 +1557,9 @@
 }
 '''
 separate_module_sources.append(get_pythonapi_source)
+kwds['post_include_bits'] = [
+'RPY_EXTERN HANDLE pypy_get_pythonapi_handle();',
+]
 
 eci = ExternalCompilationInfo(
 include_dirs=include_dirs,
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -231,7 +231,9 @@
 if os.name == 'nt':
 
 _source_code = r"""
+#ifndef _WIN32_WINNT
 #define _WIN32_WINNT 0x0501
+#endif
 #include 
 #include 
 
diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -835,7 +835,7 @@
 # assume -1 and 0 both mean invalid file descriptor
 # to 'anonymously' map memory.
 if fileno != -1 and fileno != 0:
-fh = rwin32.get_osfhandle(fileno)
+fh = rffi.cast(HANDLE, rwin32.get_osfhandle(fileno))
 # Win9x appears to need us seeked to zero
 # SEEK_SET = 0
 # libc._lseek(fileno, 0, SEEK_SET)
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -137,7 +137,10 @@
 RPY_EXTERN void exit_suppress_iph(void* handle) {};
 #endif
 ''',]
-post_include_bits=['RPY_EXTERN int _PyVerify_fd(int);']
+post_include_bits=['RPY_EXTERN int _PyVerify_fd(int);',
+   'RPY_EXTERN void* enter_suppress_iph();',
+   'RPY_EXTERN void exit_suppress_iph(void* handle);',
+  ]
 else:
 separate_module_sources = []
 post_include_bits = []
@@ -235,7 +238,8 @@
 rthread.tlfield_rpy_errno.setraw(_get_errno())
 # ^^^ keep fork() up-to-date too, below
 if _WIN32:
-includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h', 'time.h']
+includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h', 'time.h',
+'direct.h']
 libraries = []
 else:
 if sys.platform.startswith(('darwin', 'netbsd', 'openbsd')):
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -20,7 +20,7 @@
 
 if WIN32:
 eci = ExternalCompilationInfo(
-includes = ['windows.h', 'stdio.h', 'stdlib.h'],
+includes = ['windows.h', 'stdio.h', 'stdlib.h', 'io.h'],
 libraries = ['kernel32'],
 )
 else:
@@ -197,9 +197,9 @@
 LoadLibrary = winexternal('LoadLibraryA', [rffi.CCHARP], HMODULE,
   save_err=rffi.RFFI_SAVE_LASTERROR)
 def wrap_loadlibraryex(func):
-def loadlibrary(name, handle=None, 
flags=LOAD_WITH_ALTERED_SEARCH_PATH):
+def loadlibrary(name, flags=LOAD_WITH_ALTERED_SEARCH_PATH):
 # Requires a full path name with '/' -> '\\'
-return func(name, handle, flags)
+return func(name, NULL_HANDLE, flags)
 return loadlibrary
 
 _LoadLibraryExA = winexternal('LoadLibraryExA',
@@ -217,7 +217,7 @@
  rffi.VOIDP)
 FreeLibrary = winexternal('FreeLibrary', [HMODULE], BOOL, releasegil=False)
 
-LocalFree = winexternal('LocalFree', [HLOCAL], DWORD)
+LocalFree = winexternal('LocalFree', [HLOCAL], HLOCAL)
 CloseHandle = winexternal('CloseHandle', [HANDLE], BOOL, releasegil=False,
   save_err=rffi.RFFI_SAVE_LASTERROR)
 CloseHandle_no_err = winexternal('CloseHandle', [HANDLE], BOOL,
@@ -232,12 +232,12 @@
 [DWORD, rffi.VOIDP, DWORD, DWORD, rffi.CWCHARP, DWORD, rffi.VOIDP],
 DWORD)
 
-_get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], HANDLE)
+_get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], rffi.INTP)
 
 def get_osfhandle(fd):
 from rpython.rlib.rposix import FdValidator
 with FdValidator(fd):
-handle = _get_osfhandle(fd)
+handle = rffi.cast(HANDLE, _get_osfhandle(fd))
 if handle == INVALID_HANDLE_VALUE:
 raise WindowsError(ERROR_INVALID_HANDLE, "Invalid file handle")
 return handle
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.py

[pypy-commit] pypy py3.5: merge default into py3.5

2018-09-11 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95103:8f66a7558b9c
Date: 2018-09-12 00:13 +0300
http://bitbucket.org/pypy/pypy/changeset/8f66a7558b9c/

Log:merge default into py3.5

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-09-11 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95104:14f241fbf66a
Date: 2018-09-12 00:14 +0300
http://bitbucket.org/pypy/pypy/changeset/14f241fbf66a/

Log:merge default into py3.5

diff --git a/pypy/testrunner_cfg.py b/pypy/testrunner_cfg.py
--- a/pypy/testrunner_cfg.py
+++ b/pypy/testrunner_cfg.py
@@ -5,7 +5,7 @@
 'translator/c', 'rlib',
 'memory/test', 'jit/metainterp',
 'jit/backend/arm', 'jit/backend/x86',
-'jit/backend/zarch',
+'jit/backend/zarch', 'module/cpyext/test',
 ]
 
 def collect_one_testdir(testdirs, reldir, tests):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-08-31 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95049:f7324252bc6b
Date: 2018-08-31 09:05 +0200
http://bitbucket.org/pypy/pypy/changeset/f7324252bc6b/

Log:merge default into branch

diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -8,20 +8,43 @@
the same works for the other two macros.  Py_DEBUG implies them,
but not the other way around.
 
-   Issue #350 is still open: on Windows, the code here causes it to link
-   with PYTHON36.DLL (for example) instead of PYTHON3.DLL.  A fix was
-   attempted in 164e526a5515 and 14ce6985e1c3, but reverted: virtualenv
-   does not make PYTHON3.DLL available, and so the "correctly" compiled
-   version would not run inside a virtualenv.  We will re-apply the fix
-   after virtualenv has been fixed for some time.  For explanation, see
-   issue #355.  For a workaround if you want PYTHON3.DLL and don't worry
-   about virtualenv, see issue #350.  See also 'py_limited_api' in
-   setuptools_ext.py.
+   The implementation is messy (issue #350): on Windows, with _MSC_VER,
+   we have to define Py_LIMITED_API even before including pyconfig.h.
+   In that case, we guess what pyconfig.h will do to the macros above,
+   and check our guess after the #include.
+
+   Note that on Windows, with CPython 3.x, you need virtualenv version
+   >= 16.0.0.  Older versions don't copy PYTHON3.DLL.  As a workaround
+   you can remove the definition of Py_LIMITED_API here.
+
+   See also 'py_limited_api' in cffi/setuptools_ext.py.
 */
 #if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
-#  include 
-#  if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
-#define Py_LIMITED_API
+#  ifdef _MSC_VER
+#if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && 
!defined(Py_REF_DEBUG)
+#  define Py_LIMITED_API
+#endif
+#include 
+ /* sanity-check: Py_LIMITED_API will cause crashes if any of these
+are also defined.  Normally, the Python file PC/pyconfig.h does not
+cause any of these to be defined, with the exception that _DEBUG
+causes Py_DEBUG.  Double-check that. */
+#ifdef Py_LIMITED_API
+#  if defined(Py_DEBUG)
+#error "pyconfig.h unexpectedly defines Py_DEBUG, but Py_LIMITED_API 
is set"
+#  endif
+#  if defined(Py_TRACE_REFS)
+#error "pyconfig.h unexpectedly defines Py_TRACE_REFS, but 
Py_LIMITED_API is set"
+#  endif
+#  if defined(Py_REF_DEBUG)
+#error "pyconfig.h unexpectedly defines Py_REF_DEBUG, but 
Py_LIMITED_API is set"
+#  endif
+#endif
+#  else
+#include 
+#if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
+#  define Py_LIMITED_API
+#endif
 #  endif
 #endif
 
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -636,6 +636,10 @@
 if isinstance(init, bytes):
 init = [init[i:i+1] for i in range(len(init))]
 else:
+if isinstance(init, CTypesGenericArray):
+if (len(init) != len(blob) or
+not isinstance(init, CTypesArray)):
+raise TypeError("length/type mismatch: %s" % 
(init,))
 init = tuple(init)
 if len(init) > len(blob):
 raise IndexError("too many initializers")
diff --git a/lib_pypy/cffi/setuptools_ext.py b/lib_pypy/cffi/setuptools_ext.py
--- a/lib_pypy/cffi/setuptools_ext.py
+++ b/lib_pypy/cffi/setuptools_ext.py
@@ -81,13 +81,8 @@
 it doesn't so far, creating troubles.  That's why we check
 for "not hasattr(sys, 'gettotalrefcount')" (the 2.7 compatible equivalent
 of 'd' not in sys.abiflags). (http://bugs.python.org/issue28401)
-
-On Windows, it's better not to use py_limited_api until issue #355
-can be resolved (by having virtualenv copy PYTHON3.DLL).  See also
-the start of _cffi_include.h.
 """
-if ('py_limited_api' not in kwds and not hasattr(sys, 'gettotalrefcount')
-and sys.platform != 'win32'):
+if 'py_limited_api' not in kwds and not hasattr(sys, 'gettotalrefcount'):
 import setuptools
 try:
 setuptools_major_version = 
int(setuptools.__version__.partition('.')[0])
diff --git a/pypy/module/_cffi_backend/ctypearray.py 
b/pypy/module/_cffi_backend/ctypearray.py
--- a/pypy/module/_cffi_backend/ctypearray.py
+++ b/pypy/module/_cffi_backend/ctypearray.py
@@ -104,7 +104,15 @@
 return self.ctptr
 
 def convert_from_object(self, cdata, w_ob):
-self.convert_array_from_object(cdata, w_ob)
+if isinstance(w_ob, cdataobj.W_CData) and w_ob.ctype is self:
+length = w_ob.get_array_length()
+with w_ob as source:
+source = rffi.cast(rffi.VOID

[pypy-commit] pypy py3.5: merge default into py3.5

2018-08-29 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r95037:c76008be29e5
Date: 2018-08-29 08:17 +0200
http://bitbucket.org/pypy/pypy/changeset/c76008be29e5/

Log:merge default into py3.5

diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py
--- a/pypy/module/cpyext/cdatetime.py
+++ b/pypy/module/cpyext/cdatetime.py
@@ -137,8 +137,9 @@
 If it is a datetime.time or datetime.datetime, it may have tzinfo
 '''
 state = space.fromcache(State)
-# cannot raise here, so just crash
-assert len(state.datetimeAPI) > 0
+if len(state.datetimeAPI) ==0:
+# can happen in subclassing
+_PyDateTime_Import(space)
 if state.datetimeAPI[0].c_TimeType == py_obj.c_ob_type:
 py_datetime = rffi.cast(PyDateTime_Time, py_obj)
 w_tzinfo = space.getattr(w_obj, space.newtext('tzinfo'))
diff --git a/pypy/module/cpyext/include/pymath.h 
b/pypy/module/cpyext/include/pymath.h
--- a/pypy/module/cpyext/include/pymath.h
+++ b/pypy/module/cpyext/include/pymath.h
@@ -6,6 +6,74 @@
 functions and constants
 **/
 
+/* High precision definition of pi and e (Euler)
+ * The values are taken from libc6's math.h.
+ */
+#ifndef Py_MATH_PIl
+#define Py_MATH_PIl 3.1415926535897932384626433832795029L
+#endif
+#ifndef Py_MATH_PI
+#define Py_MATH_PI 3.14159265358979323846
+#endif
+
+#ifndef Py_MATH_El
+#define Py_MATH_El 2.7182818284590452353602874713526625L
+#endif
+
+#ifndef Py_MATH_E
+#define Py_MATH_E 2.7182818284590452354
+#endif
+
+/* Tau (2pi) to 40 digits, taken from tauday.com/tau-digits. */
+#ifndef Py_MATH_TAU
+#define Py_MATH_TAU 6.2831853071795864769252867665590057683943L
+#endif
+
+/* Py_IS_NAN(X)
+ * Return 1 if float or double arg is a NaN, else 0.
+ * Caution:
+ * X is evaluated more than once.
+ * This may not work on all platforms.  Each platform has *some*
+ * way to spell this, though -- override in pyconfig.h if you have
+ * a platform where it doesn't work.
+ */
+#ifndef Py_IS_NAN
+#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
+#define Py_IS_NAN(X) isnan(X)
+#else
+#define Py_IS_NAN(X) ((X) != (X))
+#endif
+#endif
+
+/* Py_IS_INFINITY(X)
+ * Return 1 if float or double arg is an infinity, else 0.
+ * Caution:
+ *X is evaluated more than once.
+ *This implementation may set the underflow flag if |X| is very small;
+ *it really can't be implemented correctly (& easily) before C99.
+ *Override in pyconfig.h if you have a better spelling on your platform.
+ */
+#ifndef Py_IS_INFINITY
+#  if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
+#define Py_IS_INFINITY(X) isinf(X)
+#  else
+#define Py_IS_INFINITY(X) ((X) && ((X)*0.5 == (X)))
+#  endif
+#endif
+
+/* Py_IS_FINITE(X)
+ * Return 1 if float or double arg is neither infinite nor NAN, else 0.
+ * Some compilers (e.g. VisualStudio) have intrisics for this, so a special
+ * macro for this particular test is useful
+ */
+#ifndef Py_IS_FINITE
+#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L
+#define Py_IS_FINITE(X) isfinite(X)
+#else
+#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))
+#endif
+#endif
+
 /* HUGE_VAL is supposed to expand to a positive double infinity.  Python
  * uses Py_HUGE_VAL instead because some platforms are broken in this
  * respect.  We used to embed code in pyport.h to try to worm around that,
diff --git a/pypy/module/cpyext/test/test_floatobject.py 
b/pypy/module/cpyext/test/test_floatobject.py
deleted file mode 100644
--- a/pypy/module/cpyext/test/test_floatobject.py
+++ /dev/null
@@ -1,112 +0,0 @@
-import pytest
-from pypy.interpreter.error import OperationError
-from pypy.module.cpyext.test.test_api import BaseApiTest
-from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
-from rpython.rtyper.lltypesystem import rffi
-from pypy.module.cpyext.floatobject import (
-PyFloat_FromDouble, PyFloat_AsDouble, PyFloat_AS_DOUBLE, PyNumber_Float,
-_PyFloat_Unpack4, _PyFloat_Unpack8)
-
-class TestFloatObject(BaseApiTest):
-def test_floatobject(self, space):
-assert space.unwrap(PyFloat_FromDouble(space, 3.14)) == 3.14
-assert PyFloat_AsDouble(space, space.wrap(23.45)) == 23.45
-assert PyFloat_AS_DOUBLE(space, space.wrap(23.45)) == 23.45
-with pytest.raises(OperationError):
-PyFloat_AsDouble(space, space.w_None)
-
-def test_coerce(self, space):
-assert space.type(PyNumber_Float(space, space.wrap(3))) is 
space.w_float
-assert space.type(PyNumber_Float(space, space.wrap("3"))) is 
space.w_float
-
-w_obj = space.appexec([], """():
-class Coerce(object):
-def __float__(self):
-return 42.5
-return Coerce()""")
-assert space.eq_w(PyNumber_Float(space, w_obj), space.wrap(42.5))
-
-def test_unpack(self, space):
-with rffi.scoped_str2charp("\x9a\x99\x99?") as ptr:
-

[pypy-commit] pypy py3.5: merge default into py3.5

2018-07-11 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94849:d367d9785b64
Date: 2018-07-11 09:20 -0500
http://bitbucket.org/pypy/pypy/changeset/d367d9785b64/

Log:merge default into py3.5

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.11.5
+Version: 1.12.0
 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
 from .error import CDefError, FFIError, VerificationError, VerificationMissing
 
-__version__ = "1.11.5"
-__version_info__ = (1, 11, 5)
+__version__ = "1.12.0"
+__version_info__ = (1, 12, 0)
 
 # 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/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -221,7 +221,7 @@
 
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.11.5"
+   "\ncompiled with cffi version: 1.12.0"
"\n_cffi_backend module: ", f);
 modules = PyImport_GetModuleDict();
 mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -96,18 +96,21 @@
 self.CData, self.CType = backend._get_types()
 self.buffer = backend.buffer
 
-def cdef(self, csource, override=False, packed=False):
+def cdef(self, csource, override=False, packed=False, pack=None):
 """Parse the given C source.  This registers all declared functions,
 types, and global variables.  The functions and global variables can
 then be accessed via either 'ffi.dlopen()' or 'ffi.verify()'.
 The types can be used in 'ffi.new()' and other functions.
 If 'packed' is specified as True, all structs declared inside this
 cdef are packed, i.e. laid out without any field alignment at all.
+Alternatively, 'pack' can be a small integer, and requests for
+alignment greater than that are ignored (pack=1 is equivalent to
+packed=True).
 """
-self._cdef(csource, override=override, packed=packed)
+self._cdef(csource, override=override, packed=packed, pack=pack)
 
-def embedding_api(self, csource, packed=False):
-self._cdef(csource, packed=packed, dllexport=True)
+def embedding_api(self, csource, packed=False, pack=None):
+self._cdef(csource, packed=packed, pack=pack, dllexport=True)
 if self._embedding is None:
 self._embedding = ''
 
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -730,7 +730,8 @@
 return self._new_struct_or_union('union', name, ctypes.Union)
 
 def complete_struct_or_union(self, CTypesStructOrUnion, fields, tp,
- totalsize=-1, totalalignment=-1, sflags=0):
+ totalsize=-1, totalalignment=-1, sflags=0,
+ pack=0):
 if totalsize >= 0 or totalalignment >= 0:
 raise NotImplementedError("the ctypes backend of CFFI does not 
support "
   "structures completed by verify(); 
please "
@@ -751,6 +752,8 @@
 bfield_types[fname] = Ellipsis
 if sflags & 8:
 struct_or_union._pack_ = 1
+elif pack:
+struct_or_union._pack_ = pack
 struct_or_union._fields_ = cfields
 CTypesStructOrUnion._bfield_types = bfield_types
 #
diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py
--- a/lib_pypy/cffi/cparser.py
+++ b/lib_pypy/cffi/cparser.py
@@ -306,11 +306,25 @@
 msg = 'parse error\n%s' % (msg,)
 raise CDefError(msg)
 
-def parse(self, csource, override=False, packed=False, dllexport=False):
+def parse(self, csource, override=False, packed=False, pack=None,
+dllexport=False):
+if packed:
+if packed != True:
+raise ValueError("'packed' should be False or True; use "
+ "'pack' to give another value")
+if pack:
+raise ValueError("cannot give both 'pack' and 'packed'")
+pack = 1
+elif pack:
+if pack & (pack - 1):
+raise ValueError("'pack' must be a powe

[pypy-commit] pypy py3.5: merge default into branch

2018-06-29 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94787:708b92b46553
Date: 2018-06-29 12:39 -0700
http://bitbucket.org/pypy/pypy/changeset/708b92b46553/

Log:merge default into branch

diff --git a/pypy/doc/sandbox.rst b/pypy/doc/sandbox.rst
--- a/pypy/doc/sandbox.rst
+++ b/pypy/doc/sandbox.rst
@@ -3,6 +3,11 @@
 PyPy's sandboxing features
 ==
 
+.. warning:: This is not actively maintained. You will likely have to fix
+   some issues yourself, or otherwise play around on your own. We provide
+   this documentation for historical reasions, it will not translate or
+   run on the latest PyPy code base.
+
 Introduction
 
 
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -658,7 +658,7 @@
 'PyType_FromSpec',
 'Py_IncRef', 'Py_DecRef', 'PyObject_Free', 'PyObject_GC_Del', 
'PyType_GenericAlloc',
 '_PyObject_New', '_PyObject_NewVar',
-'_PyObject_GC_New', '_PyObject_GC_NewVar',
+'_PyObject_GC_Malloc', '_PyObject_GC_New', '_PyObject_GC_NewVar',
 'PyObject_Init', 'PyObject_InitVar',
 'PyTuple_New', '_Py_Dealloc',
 ]
@@ -789,6 +789,9 @@
 # a pointer to PyObject
 PyObjectP = rffi.CArrayPtr(PyObject)
 
+# int *
+INTP_real = rffi.CArrayPtr(rffi.INT_real)
+
 def configure_types():
 for config in (CConfig, CConfig2):
 for name, TYPE in rffi_platform.configure(config).iteritems():
diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -372,6 +372,7 @@
 
 PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
 PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
+PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
 PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
 PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
 
diff --git a/pypy/module/cpyext/longobject.py b/pypy/module/cpyext/longobject.py
--- a/pypy/module/cpyext/longobject.py
+++ b/pypy/module/cpyext/longobject.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import lltype, rffi
 from pypy.module.cpyext.api import (
 cpython_api, PyObject, build_type_checkers_flags, Py_ssize_t,
-CONST_STRING, ADDR, CANNOT_FAIL)
+CONST_STRING, ADDR, CANNOT_FAIL, INTP_real)
 from pypy.interpreter.error import OperationError, oefmt
 from rpython.rlib.rbigint import rbigint, InvalidSignednessError
 
@@ -120,7 +120,7 @@
 num = space.bigint_w(w_long)
 return num.ulonglongmask()
 
-@cpython_api([PyObject, rffi.CArrayPtr(rffi.INT_real)], lltype.Signed,
+@cpython_api([PyObject, INTP_real], lltype.Signed,
  error=-1)
 def PyLong_AsLongAndOverflow(space, w_long, overflow_ptr):
 """
@@ -141,7 +141,7 @@
 overflow_ptr[0] = rffi.cast(rffi.INT_real, -1)
 return -1
 
-@cpython_api([PyObject, rffi.CArrayPtr(rffi.INT_real)], rffi.LONGLONG,
+@cpython_api([PyObject, INTP_real], rffi.LONGLONG,
  error=-1)
 def PyLong_AsLongLongAndOverflow(space, w_long, overflow_ptr):
 """
diff --git a/pypy/module/cpyext/pystrtod.py b/pypy/module/cpyext/pystrtod.py
--- a/pypy/module/cpyext/pystrtod.py
+++ b/pypy/module/cpyext/pystrtod.py
@@ -1,6 +1,6 @@
 import errno
 from pypy.interpreter.error import oefmt
-from pypy.module.cpyext.api import cpython_api, CONST_STRING
+from pypy.module.cpyext.api import cpython_api, CONST_STRING, INTP_real
 from pypy.module.cpyext.pyobject import PyObject
 from rpython.rlib import rdtoa
 from rpython.rlib import rfloat
@@ -80,7 +80,7 @@
 if not user_endptr:
 lltype.free(endptr, flavor='raw')
 
-@cpython_api([rffi.DOUBLE, lltype.Char, rffi.INT_real, rffi.INT_real, 
rffi.INTP], rffi.CCHARP)
+@cpython_api([rffi.DOUBLE, lltype.Char, rffi.INT_real, rffi.INT_real, 
INTP_real], rffi.CCHARP)
 def PyOS_double_to_string(space, val, format_code, precision, flags, ptype):
 """Convert a double val to a string using supplied
 format_code, precision, and flags.
@@ -114,7 +114,7 @@
 buffer, rtype = rfloat.double_to_string(val, format_code,
 intmask(precision),
 intmask(flags))
-if ptype != lltype.nullptr(rffi.INTP.TO):
-ptype[0] = rffi.cast(rffi.INT, DOUBLE_TO_STRING_TYPES_MAP[rtype])
+if ptype != lltype.nullptr(INTP_real.TO):
+ptype[0] = rffi.cast(rffi.INT_real, DOUBLE_TO_STRING_TYPES_MAP[rtype])
 bufp = rffi.str2charp(buffer)
 return bufp
diff --git a/pypy/module/cpyext/src/object.c b/pypy/module/cpyext/src/object.c
--- a/pypy/module/cpyext/src/object.c
+++ b/pypy/module/cpyext/src/object.c
@@ -60,6 +60,11 @@
 return (PyObject*)_PyObject_NewVar(type, 0);
 }
 
+PyObject * _PyObject_GC_Malloc(size_t size)
+{
+return (PyObject *)PyObject_Malloc(size);
+}
+
 PyObject * _PyObject_GC_New(PyTypeObject *type)
 {
 return _PyObject_New(type);
diff --git a/p

[pypy-commit] pypy py3.5: merge default into branch

2018-06-08 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94745:2e791fab4895
Date: 2018-06-09 06:10 -0700
http://bitbucket.org/pypy/pypy/changeset/2e791fab4895/

Log:merge default into branch

diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -29,29 +29,28 @@
 ``C:\Users\\AppData\Local\Programs\Common\Microsoft\Visual C++ for 
Python``
 or in
 ``C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python``.
-A current version of ``setuptools`` will be able to find it there. For
-Windows 10, you must right-click the download, and under ``Properties`` ->
-``Compatibility`` mark it as ``Run run this program in comatibility mode for``
-``Previous version...``. Also, you must download and install the ``.Net 
Framework 3.5``,
+A current version of ``setuptools`` will be able to find it there.
+Also, you must download and install the ``.Net Framework 3.5``,
 otherwise ``mt.exe`` will silently fail. Installation will begin automatically
 by running the mt.exe command by hand from a DOS window (that is how the author
 discovered the problem).
 
 .. _Microsoft Visual C++ Compiler for Python 2.7: 
https://www.microsoft.com/EN-US/DOWNLOAD/DETAILS.ASPX?ID=44266
 
-Installing "Build Tools for Visual Studio 2017" (for Python 3)
+Installing "Build Tools for Visual Studio 2015" (for Python 3)
 --
 
-As documented in the CPython Wiki_, CPython now recommends Visual C++ version
-14.0. A compact version of the compiler suite can be obtained from Microsoft_
-downloads, search the page for "Build Tools for Visual Studio 2017".
+As documented in the CPython Wiki_, CPython recommends Visual C++ version
+14.0 for python version 3.5. A compact version of the compiler suite can be 
+obtained from Microsoft_ downloads, search the page for "Microsoft Build Tools 
2015".
 
-You will also need to install the the `Windows SDK`_ in order to use the 
-`mt.exe` mainfest compiler.
+You will need to reboot the computer for the installation to successfully 
install and
+run the `mt.exe` mainfest compiler. The installation will set the
+`VS140COMNTOOLS` environment variable, this is key to distutils/setuptools
+finding the compiler
 
 .. _Wiki: https://wiki.python.org/moin/WindowsCompilers
-.. _Microsoft: https://www.visualstudio.com/downloads
-.. _`Windows SDK`: 
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
+.. _Microsoft: https://www.visualstudio.com/vs/older-downloads/
 
 Translating PyPy with Visual Studio
 ---
@@ -99,6 +98,9 @@
 Setting Up Visual Studio 9.0 for building SSL in Python3
 
 
+**Note: this is old information, left for historical reference. We recommend
+using Visual Studio 2015, which now seems to properly set this all up.**
+
 On Python3, the ``ssl`` module is based on ``cffi``, and requires a build step 
after
 translation. However ``distutils`` does not support the Micorosft-provided 
Visual C
 compiler, and ``cffi`` depends on ``distutils`` to find the compiler. The
@@ -146,14 +148,14 @@
 Installing external packages
 
 
-We uses a `repository` parallel to pypy to hold binary compiled versions of the
+We uses a subrepository_ inside pypy to hold binary compiled versions of the
 build dependencies for windows. As part of the `rpython` setup stage, 
environment
 variables will be set to use these dependencies. The repository has a README
 file on how to replicate, and a branch for each supported platform. You may run
 the `get_externals.py` utility to checkout the proper branch for your platform
 and PyPy version.
 
-.. _repository:  https://bitbucket.org/pypy/external
+.. _subrepository:  https://bitbucket.org/pypy/external
 
 Using the mingw compiler
 
diff --git a/pypy/module/cpyext/include/pyconfig.h 
b/pypy/module/cpyext/include/pyconfig.h
--- a/pypy/module/cpyext/include/pyconfig.h
+++ b/pypy/module/cpyext/include/pyconfig.h
@@ -31,16 +31,27 @@
 #endif
 
 #ifndef Py_BUILD_CORE /* not building the core - must be an ext */
-#if defined(_MSC_VER) && !defined(_CFFI_)
- /* So MSVC users need not specify the .lib file in
-  * their Makefile (other compilers are generally
-  * taken care of by distutils.) */
-#ifdef _DEBUG
-#error("debug first with cpython")
+#  if defined(_MSC_VER) && !defined(_CFFI_)
+   /* So MSVC users need not specify the .lib file in
+* their Makefile (other compilers are generally
+* taken care of by distutils.) 
+*/
+#ifdef _DEBUG
+#  error("debug first with cpython")
 #pragma comment(lib,"python35.lib")
-#else
+#else
 #pragma comment(lib,"python35.lib")
-#endif /* _DEBUG */
+#endif /* _DEBUG */
+#define HAVE_COPYSIGN 1
+#define copysign _copysign
+#ifdef MS_WIN64
+   typedef __int64 ssize_

[pypy-commit] pypy py3.5: merge default into py3.5

2018-05-21 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94651:39fd746993fe
Date: 2018-05-21 21:34 -0700
http://bitbucket.org/pypy/pypy/changeset/39fd746993fe/

Log:merge default into py3.5

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -18,3 +18,7 @@
 .. branch: crypt_h
 
 Include crypt.h for crypt() on Linux
+
+.. branch: gc-more-logging
+
+Log additional gc-minor and gc-collect-step info in the PYPYLOG
diff --git a/pypy/module/__pypy__/test/test_special.py 
b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -135,7 +135,10 @@
 cls.w_runappdirect = cls.space.wrap(cls.runappdirect)
 
 def test_jit_backend_features(self):
-from __pypy__ import jit_backend_features
+try:
+from __pypy__ import jit_backend_features
+except ImportError:
+skip("compiled without jit")
 supported_types = jit_backend_features
 assert isinstance(supported_types, list)
 for x in supported_types:
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -660,7 +660,7 @@
 '_PyObject_New', '_PyObject_NewVar',
 '_PyObject_GC_New', '_PyObject_GC_NewVar',
 'PyObject_Init', 'PyObject_InitVar',
-'PyTuple_New',
+'PyTuple_New', '_Py_Dealloc',
 ]
 TYPES = {}
 FORWARD_DECLS = []
@@ -1150,10 +1150,11 @@
 
 def attach_c_functions(space, eci, prefix):
 state = space.fromcache(State)
-state.C._Py_Dealloc = rffi.llexternal('_Py_Dealloc',
- [PyObject], lltype.Void,
- compilation_info=eci,
- _nowrapper=True)
+state.C._Py_Dealloc = rffi.llexternal(
+mangle_name(prefix, '_Py_Dealloc'),
+[PyObject], lltype.Void,
+compilation_info=eci,
+_nowrapper=True)
 state.C.PyObject_Free = rffi.llexternal(
 mangle_name(prefix, 'PyObject_Free'),
 [rffi.VOIDP], lltype.Void,
diff --git a/pypy/objspace/std/dictmultiobject.py 
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -226,13 +226,7 @@
 """Not exposed directly to app-level, but via __pypy__.reversed_dict().
 """
 strategy = self.get_strategy()
-if strategy.has_iterreversed:
-it = strategy.iterreversed(self)
-return W_DictMultiIterKeysObject(space, it)
-else:
-# fall-back
-w_keys = self.w_keys()
-return space.call_method(w_keys, '__reversed__')
+return strategy.iterreversed(self)
 
 def nondescr_delitem_if_value_is(self, space, w_key, w_value):
 """Not exposed directly to app-level, but used by
@@ -246,32 +240,7 @@
 """Not exposed directly to app-level, but via __pypy__.move_to_end().
 """
 strategy = self.get_strategy()
-if strategy.has_move_to_end:
-strategy.move_to_end(self, w_key, last_flag)
-else:
-# fall-back
-w_value = self.getitem(w_key)
-if w_value is None:
-space.raise_key_error(w_key)
-else:
-self.internal_delitem(w_key)
-if last_flag:
-self.setitem(w_key, w_value)
-else:
-# *very slow* fall-back
-keys_w = []
-values_w = []
-iteratorimplementation = self.iteritems()
-while True:
-w_k, w_v = iteratorimplementation.next_item()
-if w_k is None:
-break
-keys_w.append(w_k)
-values_w.append(w_v)
-self.clear()
-self.setitem(w_key, w_value)
-for i in range(len(keys_w)):
-self.setitem(keys_w[i], values_w[i])
+strategy.move_to_end(self, w_key, last_flag)
 
 def nondescr_popitem_first(self, space):
 """Not exposed directly to app-level, but via __pypy__.popitem_first().
@@ -298,21 +267,10 @@
 otherwise KeyError is raised
 """
 strategy = self.get_strategy()
-if strategy.has_pop:
-try:
-return strategy.pop(self, w_key, w_default)
-except KeyError:
-raise space.raise_key_error(w_key)
-# fall-back
-w_item = self.getitem(w_key)
-if w_item is None:
-if w_default is not None:
-return w_default
-else:
-space.raise_key_error(w_key)
-else:
-self.internal_delitem(w_key)
-return w_item
+try:
+  

[pypy-commit] pypy py3.5: merge default into py3.5

2018-05-14 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94571:823fbc19cb92
Date: 2018-05-14 14:56 +0300
http://bitbucket.org/pypy/pypy/changeset/823fbc19cb92/

Log:merge default into py3.5

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -1176,8 +1176,8 @@
 '_PyPy_tuple_dealloc', [PyObject], lltype.Void,
 compilation_info=eci, _nowrapper=True)
 _, state.C.set_marker = rffi.CExternVariable(
-   Py_ssize_t, '_pypy_rawrefcount_w_marker_deallocating',
-   eci, _nowrapper=True, c_type='Py_ssize_t')
+   rffi.VOIDP, '_pypy_rawrefcount_w_marker_deallocating',
+   eci, _nowrapper=True, c_type='void *')
 state.C._PyPy_subtype_dealloc = rffi.llexternal(
 '_PyPy_subtype_dealloc', [PyObject], lltype.Void,
 compilation_info=eci, _nowrapper=True)
diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -61,7 +61,7 @@
 #endif
 PyAPI_FUNC(void) Py_IncRef(PyObject *);
 PyAPI_FUNC(void) Py_DecRef(PyObject *);
-extern Py_ssize_t _pypy_rawrefcount_w_marker_deallocating;
+extern void *_pypy_rawrefcount_w_marker_deallocating;
 PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
 
 
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -410,7 +410,7 @@
 if we_are_translated():
 llptr = cast_instance_to_base_ptr(w_marker_deallocating)
 state = space.fromcache(State)
-state.C.set_marker(rffi.cast(Py_ssize_t, llptr))
+state.C.set_marker(llptr)
 
 @cpython_api([rffi.VOIDP], lltype.Signed, error=CANNOT_FAIL)
 def _Py_HashPointer(space, ptr):
diff --git a/pypy/module/cpyext/src/object.c b/pypy/module/cpyext/src/object.c
--- a/pypy/module/cpyext/src/object.c
+++ b/pypy/module/cpyext/src/object.c
@@ -14,14 +14,14 @@
  * tests we cannot call set_marker(), so we need to set a special value
  * directly here)
  */
-Py_ssize_t _pypy_rawrefcount_w_marker_deallocating = 0xDEADFFF;
+void* _pypy_rawrefcount_w_marker_deallocating = (void*) 0xDEADFFF;
 
 void
 _Py_Dealloc(PyObject *obj)
 {
 PyTypeObject *pto = obj->ob_type;
 /* this is the same as rawrefcount.mark_deallocating() */
-obj->ob_pypy_link = _pypy_rawrefcount_w_marker_deallocating;
+obj->ob_pypy_link = (Py_ssize_t)_pypy_rawrefcount_w_marker_deallocating;
 pto->tp_dealloc(obj);
 }
 
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -1222,13 +1222,6 @@
 version indicates the file format."""
 raise NotImplementedError
 
-@cpython_api([PyObject, rffi.INT_real], PyObject)
-def PyMarshal_WriteObjectToString(space, value, version):
-"""Return a string object containing the marshalled representation of 
value.
-
-version indicates the file format."""
-raise NotImplementedError
-
 @cpython_api([FILE], lltype.Signed, error=-1)
 def PyMarshal_ReadLongFromFile(space, file):
 """Return a C long from the data stream in a FILE* opened
@@ -1262,14 +1255,6 @@
 (EOFError or TypeError) and returns NULL."""
 raise NotImplementedError
 
-@cpython_api([rffi.CCHARP, Py_ssize_t], PyObject)
-def PyMarshal_ReadObjectFromString(space, string, len):
-"""Return a Python object from the data stream in a character buffer
-containing len bytes pointed to by string.  On error, sets the
-appropriate exception (EOFError or TypeError) and returns
-NULL."""
-raise NotImplementedError
-
 @cpython_api([PyObject, rffi.INT_real, lltype.Char], PyObject)
 def PyMemoryView_GetContiguous(space, obj, buffertype, order):
 """Create a memoryview object to a contiguous chunk of memory (in either
diff --git a/pypy/module/cpyext/test/test_marshal.py 
b/pypy/module/cpyext/test/test_marshal.py
--- a/pypy/module/cpyext/test/test_marshal.py
+++ b/pypy/module/cpyext/test/test_marshal.py
@@ -6,8 +6,8 @@
 module = self.import_extension('foo', [
 ("mloads", "METH_O",
  """
- char *input = PyString_AsString(args);
- Py_ssize_t length = PyString_Size(args);
+ char *input = PyBytes_AsString(args);
+ Py_ssize_t length = PyBytes_Size(args);
  return PyMarshal_ReadObjectFromString(input, length);
  """)],
 prologue='#include ')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-05-12 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94538:5f017005bd26
Date: 2018-05-12 21:01 +0300
http://bitbucket.org/pypy/pypy/changeset/5f017005bd26/

Log:merge default into py3.5

diff --git a/pypy/doc/config/objspace.usemodules._cppyy.txt 
b/pypy/doc/config/objspace.usemodules._cppyy.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/config/objspace.usemodules._cppyy.txt
@@ -0,0 +1,1 @@
+The internal backend for cppyy
diff --git a/pypy/doc/config/objspace.usemodules._rawffi.txt 
b/pypy/doc/config/objspace.usemodules._rawffi.txt
--- a/pypy/doc/config/objspace.usemodules._rawffi.txt
+++ b/pypy/doc/config/objspace.usemodules._rawffi.txt
@@ -1,3 +1,3 @@
-An experimental module providing very low-level interface to
+A module providing very low-level interface to
 C-level libraries, for use when implementing ctypes, not
-intended for a direct use at all.
\ No newline at end of file
+intended for a direct use at all.
diff --git a/pypy/doc/config/objspace.usemodules.cpyext.txt 
b/pypy/doc/config/objspace.usemodules.cpyext.txt
--- a/pypy/doc/config/objspace.usemodules.cpyext.txt
+++ b/pypy/doc/config/objspace.usemodules.cpyext.txt
@@ -1,1 +1,1 @@
-Use (experimental) cpyext module, that tries to load and run CPython extension 
modules
+Use cpyext module to load and run CPython extension modules
diff --git a/pypy/doc/contributing.rst b/pypy/doc/contributing.rst
--- a/pypy/doc/contributing.rst
+++ b/pypy/doc/contributing.rst
@@ -293,7 +293,8 @@
 
 You will need the `build requirements`_ to run tests successfully, since many 
of
 them compile little pieces of PyPy and then run the tests inside that minimal
-interpreter
+interpreter. The `cpyext` tests also require `pycparser`, and many tests build
+cases with `hypothesis`.
 
 Now on to running some tests.  PyPy has many different test directories
 and you can use shell completion to point at directories or files::
@@ -325,6 +326,24 @@
 .. _py.test usage and invocations: http://pytest.org/latest/usage.html#usage
 .. _`build requirements`: build.html#install-build-time-dependencies
 
+Testing After Translation
+^
+
+While the usual invocation of `pytest` translates a piece of RPython code and
+runs it, we have a test extension to run tests without translation, directly
+on the host python. This is very convenient for modules such as `cpyext`, to
+compare and contrast test results between CPython and PyPy. Untranslated tests
+are invoked by using the `-A` or `--runappdirect` option to `pytest`::
+
+python2 pytest.py -A pypy/module/cpyext/test
+
+where `python2` can be either `python2` or `pypy2`. On the `py3` branch, the
+collection phase must be run with `python2` so untranslated tests are run
+with::
+
+cpython2 pytest.py -A pypy/module/cpyext/test --python=path/to/pypy3
+
+
 Tooling & Utilities
 ^^^
 
diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst
--- a/pypy/doc/index.rst
+++ b/pypy/doc/index.rst
@@ -41,7 +41,7 @@
 --
 
 .. toctree::
-  :maxdepth: 1
+  :maxdepth: 2
 
   cpython_differences
   extending
@@ -56,7 +56,7 @@
 ---
 
 .. toctree::
-  :maxdepth: 1
+  :maxdepth: 2
 
   contributing
   architecture
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -529,7 +529,8 @@
 
 def visit_kwonly(self, typ):
 raise FastFuncNotSupported
-
+
+@staticmethod
 def make_fastfunc(unwrap_spec, func):
 unwrap_info = UnwrapSpec_FastFunc_Unwrap()
 unwrap_info.apply_over(unwrap_spec)
@@ -560,7 +561,6 @@
 exec compile2(source) in unwrap_info.miniglobals, d
 fastfunc = d['fastfunc_%s_%d' % (func.__name__.replace('-', '_'), 
narg)]
 return narg, fastfunc
-make_fastfunc = staticmethod(make_fastfunc)
 
 
 def int_unwrapping_space_method(typ):
diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -27,10 +27,9 @@
 @unwrap_spec(code=int)
 def chr(space, code):
 "Return a Unicode string of one character with the given ordinal."
-try:
-c = UNICHR(code)
-except ValueError:
+if code < 0 or code > 0x10:
 raise oefmt(space.w_ValueError, "chr() arg out of range")
+c = UNICHR(code)
 return space.newunicode(c)
 
 def len(space, w_obj):
diff --git a/pypy/module/cpyext/__init__.py b/pypy/module/cpyext/__init__.py
--- a/pypy/module/cpyext/__init__.py
+++ b/pypy/module/cpyext/__init__.py
@@ -76,6 +76,7 @@
 import pypy.module.cpyext.pytraceback
 import pypy.module.cpyext.methodobject
 import pypy.module.cpyext.dictproxyobject
+import pypy.module.cpyext.marshal
 import pypy.module.cpyext.genobject
 import pypy.module.cpyext.namespaceobject
 
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -61,7 +61,7 @@
 
 config

[pypy-commit] pypy py3.5: merge default into py3.5

2018-05-06 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94479:2885e6b1619d
Date: 2018-05-06 22:26 +0300
http://bitbucket.org/pypy/pypy/changeset/2885e6b1619d/

Log:merge default into py3.5

diff --git a/rpython/jit/metainterp/optimizeopt/info.py 
b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -260,6 +260,12 @@
 # we don't know about this item
 return
 op = 
optimizer.get_box_replacement(self._fields[fielddescr.get_index()])
+if op is None:
+# XXX same bug as in serialize_opt:
+# op should never be None, because that's an invariant violation in
+# AbstractCachedEntry. But it still seems to happen when the info
+# is attached to a Constant. At least we shouldn't crash.
+return
 opnum = OpHelpers.getfield_for_descr(fielddescr)
 getfield_op = ResOperation(opnum, [structbox], descr=fielddescr)
 shortboxes.add_heap_op(op, getfield_op)
@@ -589,6 +595,7 @@
 return
 item = self._items[index]
 if item is not None:
+# see comment in AbstractStructPtrInfo.produce_short_preamble_ops
 op = optimizer.get_box_replacement(item)
 opnum = OpHelpers.getarrayitem_for_descr(descr)
 getarrayitem_op = ResOperation(opnum, [structbox, ConstInt(index)],
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -550,7 +550,7 @@
 self.family = family
 self.type = type
 self.proto = proto
-self.timeout = defaults.timeout
+self.settimeout(defaults.timeout)
 
 @staticmethod
 def empty_rsocket():
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -465,6 +465,15 @@
 s.connect(INETAddress('python.org', 80))
 s.close()
 
+def test_connect_with_default_timeout_fail():
+rsocket.setdefaulttimeout(0.1)
+s = RSocket()
+rsocket.setdefaulttimeout(None)
+assert s.gettimeout() == 0.1
+with py.test.raises(SocketTimeout):
+s.connect(INETAddress('172.30.172.30', 12345))
+s.close()
+
 def test_getsetsockopt():
 import struct
 assert struct.calcsize("i") == rffi.sizeof(rffi.INT)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-04-30 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94457:8a3e586cc749
Date: 2018-04-29 20:56 +0300
http://bitbucket.org/pypy/pypy/changeset/8a3e586cc749/

Log:merge default into py3.5

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -51,3 +51,5 @@
  release-pypy3.5-v5.10.0
 09f9160b643e3f02ccb8c843b2fbb4e5cbf54082 release-pypy3.5-v5.10.0
 3f6eaa010fce78cc7973bdc1dfdb95970f08fed2 release-pypy3.5-v5.10.1
+ab0b9caf307db6592905a80b8faffd69b39005b8 release-pypy2.7-v6.0.0
+fdd60ed87e941677e8ea11acf9f1819466521bf2 release-pypy3.5-v6.0.0
diff --git a/dotviewer/font/NOTICE b/dotviewer/font/COPYING.txt
rename from dotviewer/font/NOTICE
rename to dotviewer/font/COPYING.txt
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -81,8 +81,11 @@
 def _CData_output(self, resarray, base=None, index=-1):
 from _rawffi.alt import types
 # If a char_p or unichar_p is received, skip the string interpretation
-if base._ffiargtype != types.Pointer(types.char_p) and \
-   base._ffiargtype != types.Pointer(types.unichar_p):
+try:
+deref = type(base)._deref_ffiargtype()
+except AttributeError:
+deref = None
+if deref != types.char_p and deref != types.unichar_p:
 # this seems to be a string if we're array of char, surprise!
 from ctypes import c_char, c_wchar
 if self._type_ is c_char:
@@ -127,6 +130,12 @@
 value = self(*value)
 return _CDataMeta.from_param(self, value)
 
+def _build_ffiargtype(self):
+return _ffi.types.Pointer(self._type_.get_ffi_argtype())
+
+def _deref_ffiargtype(self):
+return self._type_.get_ffi_argtype()
+
 def array_get_slice_params(self, index):
 if hasattr(self, '_length_'):
 start, stop, step = index.indices(self._length_)
@@ -254,6 +263,5 @@
 _type_ = base
 )
 cls = ArrayMeta(name, (Array,), tpdict)
-cls._ffiargtype = _ffi.types.Pointer(base.get_ffi_argtype())
 ARRAY_CACHE[key] = cls
 return cls
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -49,10 +49,13 @@
 else:
 return self.from_param(as_parameter)
 
+def _build_ffiargtype(self):
+return _shape_to_ffi_type(self._ffiargshape_)
+
 def get_ffi_argtype(self):
 if self._ffiargtype:
 return self._ffiargtype
-self._ffiargtype = _shape_to_ffi_type(self._ffiargshape_)
+self._ffiargtype = self._build_ffiargtype()
 return self._ffiargtype
 
 def _CData_output(self, resbuffer, base=None, index=-1):
diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -70,7 +70,12 @@
 self._ffiarray = ffiarray
 self.__init__ = __init__
 self._type_ = TP
-self._ffiargtype = _ffi.types.Pointer(TP.get_ffi_argtype())
+
+def _build_ffiargtype(self):
+return _ffi.types.Pointer(self._type_.get_ffi_argtype())
+
+def _deref_ffiargtype(self):
+return self._type_.get_ffi_argtype()
 
 from_address = cdata_from_address
 
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -160,6 +160,10 @@
 raise AttributeError("_fields_ is final")
 if self in [f[1] for f in value]:
 raise AttributeError("Structure or union cannot contain itself")
+if self._ffiargtype is not None:
+raise NotImplementedError("Too late to set _fields_: we already "
+"said to libffi that the structure type %s is opaque"
+% (self,))
 names_and_fields(
 self,
 value, self.__bases__[0],
diff --git a/pypy/doc/gc_info.rst b/pypy/doc/gc_info.rst
--- a/pypy/doc/gc_info.rst
+++ b/pypy/doc/gc_info.rst
@@ -152,7 +152,7 @@
 to wait until it reaches a point in which the interpreter is in a known state
 and calling user-defined code is harmless.  It might happen that multiple
 events occur before the hook is invoked: in this case, you can inspect the
-value ``stats.count`` to know how many times the event occured since the last
+value ``stats.count`` to know how many times the event occurred since the last
 time the hook was called.  Similarly, ``stats.duration`` contains the
 **total** time spent by the GC for this specific event since the last time the
 hook was called.
@@ -163,7 +163,7 @@
 The attributes for ``GcMinorStats`` are:
 
 ``count``
-The number of minor collections occured since the last hook call.
+The number of minor collections occurred since the last hook call.
 
 ``duration``
 The total time spent inside minor

[pypy-commit] pypy py3.5: merge default into branch

2018-04-23 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94439:6416cd28171a
Date: 2018-04-24 09:04 +0300
http://bitbucket.org/pypy/pypy/changeset/6416cd28171a/

Log:merge default into branch

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -247,6 +247,7 @@
   Lukas Vacek
   Omer Katz
   Jacek Generowicz
+  Tomasz Dziopa
   Sylvain Thenault
   Jakub Stasiak
   Andrew Dalke
@@ -307,6 +308,7 @@
   Yury V. Zaytsev
   florinpapa
   Anders Sigfridsson
+  Matt Jackson
   Nikolay Zinov
   rafalgalczyn...@gmail.com
   Joshua Gilbert
diff --git a/pypy/doc/contributor.rst b/pypy/doc/contributor.rst
--- a/pypy/doc/contributor.rst
+++ b/pypy/doc/contributor.rst
@@ -214,6 +214,7 @@
   Lukas Vacek
   Omer Katz
   Jacek Generowicz
+  Tomasz Dziopa
   Sylvain Thenault
   Jakub Stasiak
   Andrew Dalke
@@ -274,6 +275,7 @@
   Yury V. Zaytsev
   florinpapa
   Anders Sigfridsson
+  Matt Jackson
   Nikolay Zinov
   rafalgalczyn...@gmail.com
   Joshua Gilbert
diff --git a/pypy/doc/release-v6.0.0.rst b/pypy/doc/release-v6.0.0.rst
--- a/pypy/doc/release-v6.0.0.rst
+++ b/pypy/doc/release-v6.0.0.rst
@@ -20,16 +20,18 @@
 
 The GC now has `hooks`_ to gain more insights into its performance
 
-The Windows PyPy3.5 release is still considered beta-quality. There are open
-issues with unicode handling especially around system calls and c-extensions.
+The Matplotlib TkAgg backend now works with PyPy, as do pygame and pygobject_.
 
-The Matplotlib TkAgg backend now works with PyPy, as do pygame and pygobject_.
+We updated the `cffi`_ module included in PyPy to version 1.11.5, and the
+`cppyy`_ backend to 0.6.0. Please use these to wrap your C and C++ code,
+respectively, for a JIT friendly experience.
 
 As always, this release is 100% compatible with the previous one and fixed
 several issues and bugs raised by the growing community of PyPy users.
 We strongly recommend updating.
 
-We updated the cffi module included in PyPy to version 1.11.5
+The Windows PyPy3.5 release is still considered beta-quality. There are open
+issues with unicode handling especially around system calls and c-extensions.
 
 The utf8 branch that changes internal representation of unicode to utf8 did not
 make it into the release, so there is still more goodness coming. We also
@@ -56,6 +58,8 @@
 .. _pygobject: https://lazka.github.io/posts/2018-04_pypy-pygobject/index.html
 .. _`syntax errors`: 
https://morepypy.blogspot.com/2018/04/improving-syntaxerror-in-pypy.html
 .. _`hooks`: gc_info.html#gc-hooks
+.. _`cffi`: http://cffi.readthedocs.io
+.. _`cppyy`: https://cppyy.readthedocs.io
 
 What is PyPy?
 =
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -3,7 +3,7 @@
 ==
 
 .. this is a revision shortly after release-pypy-6.0.0
-.. startrev: ad79cc0ce9a8
+.. startrev: e50e11af23f1
 
 
 
diff --git a/pypy/doc/whatsnew-pypy2-6.0.0.rst 
b/pypy/doc/whatsnew-pypy2-6.0.0.rst
--- a/pypy/doc/whatsnew-pypy2-6.0.0.rst
+++ b/pypy/doc/whatsnew-pypy2-6.0.0.rst
@@ -125,4 +125,8 @@
 
 .. branch: gc-hook-better-timestamp
 
-Improve GC hooksd
+Improve GC hooks
+
+.. branch: cppyy-packaging
+
+Update backend to 0.6.0 and support exceptions through wrappers
diff --git a/pypy/interpreter/executioncontext.py 
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -479,11 +479,17 @@
 # 'action.fire()' happens to be called any time before
 # the corresponding perform(), the fire() has no
 # effect---which is the effect we want, because
-# perform() will be called anyway.
+# perform() will be called anyway.  All such pending
+# actions with _fired == True are still inside the old
+# chained list.  As soon as we reset _fired to False,
+# we also reset _next to None and we are ready for
+# another fire().
 while action is not None:
+next_action = action._next
+action._next = None
 action._fired = False
 action.perform(ec, frame)
-action._next, action = None, action._next
+action = next_action
 
 self.action_dispatcher = action_dispatcher
 
diff --git a/pypy/interpreter/test/test_executioncontext.py 
b/pypy/interpreter/test/test_executioncontext.py
--- a/pypy/interpreter/test/test_executioncontext.py
+++ b/pypy/interpreter/test/test_executioncontext.py
@@ -66,6 +66,47 @@
 """)
 assert events == ['one']
 
+def test_fire_inside_perform(self):
+# test what happens if we call AsyncAction.fire() while we are in the
+# middle of an AsyncAction.perform(). In particular, this happens when
+# PyObjectDeallocAction.fire() is called by rawrefcount: see issue
+# 2805
+  

[pypy-commit] pypy py3.5: merge default into py3.5

2018-04-20 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94393:580e3e26cd32
Date: 2018-04-20 14:21 +0300
http://bitbucket.org/pypy/pypy/changeset/580e3e26cd32/

Log:merge default into py3.5

diff --git a/pypy/doc/release-v6.0.0.rst b/pypy/doc/release-v6.0.0.rst
--- a/pypy/doc/release-v6.0.0.rst
+++ b/pypy/doc/release-v6.0.0.rst
@@ -18,6 +18,8 @@
 getting started writing code. We have improved our parser to emit more friendly
 `syntax errors`_,  making PyPy not only faster but more friendly.
 
+The GC now has `hooks`_ to gain more insights into its performance
+
 The Windows PyPy3.5 release is still considered beta-quality. There are open
 issues with unicode handling especially around system calls and c-extensions.
 
@@ -53,6 +55,7 @@
 .. _`blog post`: 
https://morepypy.blogspot.it/2017/10/cape-of-good-hope-for-pypy-hello-from.html
 .. _pygobject: https://lazka.github.io/posts/2018-04_pypy-pygobject/index.html
 .. _`syntax errors`: 
https://morepypy.blogspot.com/2018/04/improving-syntaxerror-in-pypy.html
+.. _`hooks`: gc_info.html#gc-hooks
 
 What is PyPy?
 =
@@ -101,8 +104,9 @@
 * Added missing attributes to C-API ``instancemethod`` on pypy3
 * Store error state in thread-local storage for C-API.
 * Fix JIT bugs exposed in the sre module
-* Improve speed of Python parser, improve ParseError messages slightly
+* Improve speed of Python parser, improve ParseError messages and SyntaxError
 * Handle JIT hooks more efficiently
+* Fix a rare GC bug exposed by intensive use of cpyext `Buffer` s
 
 We also refactored many parts of the JIT bridge optimizations, as well as 
cpyext
 internals, and together with new contributors fixed issues, added new
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -3,18 +3,7 @@
 ==
 
 .. this is a revision shortly after release-pypy-6.0.0
-.. startrev: f22145c34985
+.. startrev: ad79cc0ce9a8
 
 
-.. branch: issue2752
 
-Fix a rare GC bug that was introduced more than one year ago, but was
-not diagnosed before issue #2752.
-
-.. branch: gc-hooks
-
-Introduce GC hooks, as documented in doc/gc_info.rst
-
-.. branch: gc-hook-better-timestamp
-
-Improve GC hooks
diff --git a/pypy/doc/whatsnew-pypy2-6.0.0.rst 
b/pypy/doc/whatsnew-pypy2-6.0.0.rst
--- a/pypy/doc/whatsnew-pypy2-6.0.0.rst
+++ b/pypy/doc/whatsnew-pypy2-6.0.0.rst
@@ -113,3 +113,16 @@
 
 Improve line offsets that are reported by SyntaxError. Improve error messages
 for a few situations, including mismatched parenthesis.
+
+.. branch: issue2752
+
+Fix a rare GC bug that was introduced more than one year ago, but was
+not diagnosed before issue #2752.
+
+.. branch: gc-hooks
+
+Introduce GC hooks, as documented in doc/gc_info.rst
+
+.. branch: gc-hook-better-timestamp
+
+Improve GC hooksd
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-04-19 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94388:a5488a8c8485
Date: 2018-04-19 23:41 +0300
http://bitbucket.org/pypy/pypy/changeset/a5488a8c8485/

Log:merge default into branch

diff --git a/pypy/module/cpyext/test/test_arraymodule.py 
b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -187,7 +187,4 @@
 self.attrib = True
 import gc
 module.subclass_with_attribute(Sub, "addattrib", "attrib", gc.collect)
-if self.runappdirect:
-assert Sub.__module__ == 'pypy.module.cpyext.test.test_arraymodule'
-assert str(Sub) == ""
-
+assert Sub.__module__ == __name__
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
@@ -27,11 +27,8 @@
  if(PyUnicode_GetSize(s) != 11) {
  result = -PyUnicode_GetSize(s);
  }
-#ifdef PYPY_VERSION
- // Slightly silly test that tp_basicsize is reasonable.
- if(s->ob_type->tp_basicsize != sizeof(void*)*12)
+ if(s->ob_type->tp_basicsize != sizeof(PyUnicodeObject))
  result = s->ob_type->tp_basicsize;
-#endif  // PYPY_VERSION
  Py_DECREF(s);
  return PyLong_FromLong(result);
  """),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-04-19 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94381:127336ebfcfe
Date: 2018-04-19 11:20 +0300
http://bitbucket.org/pypy/pypy/changeset/127336ebfcfe/

Log:merge default into branch

diff --git a/pypy/doc/gc_info.rst b/pypy/doc/gc_info.rst
--- a/pypy/doc/gc_info.rst
+++ b/pypy/doc/gc_info.rst
@@ -169,6 +169,12 @@
 The total time spent inside minor collections since the last hook
 call. See below for more information on the unit.
 
+``duration_min``
+The duration of the fastest minor collection since the last hook call.
+
+``duration_max``
+The duration of the slowest minor collection since the last hook call.
+
  ``total_memory_used``
 The amount of memory used at the end of the minor collection, in
 bytes. This include the memory used in arenas (for GC-managed memory) and
@@ -180,7 +186,7 @@
 
 The attributes for ``GcCollectStepStats`` are:
 
-``count``, ``duration``
+``count``, ``duration``, ``duration_min``, ``duration_max``
 See above.
 
 ``oldstate``, ``newstate``
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -14,3 +14,7 @@
 .. branch: gc-hooks
 
 Introduce GC hooks, as documented in doc/gc_info.rst
+
+.. branch: gc-hook-better-timestamp
+
+Improve GC hooks
diff --git a/pypy/module/__pypy__/interp_debug.py 
b/pypy/module/__pypy__/interp_debug.py
--- a/pypy/module/__pypy__/interp_debug.py
+++ b/pypy/module/__pypy__/interp_debug.py
@@ -3,9 +3,12 @@
 from rpython.rlib import rtimer
 
 @jit.dont_look_inside
-@unwrap_spec(category='text')
-def debug_start(space, category):
-debug.debug_start(category)
+@unwrap_spec(category='text', timestamp=bool)
+def debug_start(space, category, timestamp=False):
+res = debug.debug_start(category, timestamp=timestamp)
+if timestamp:
+return space.newint(res)
+return space.w_None
 
 @jit.dont_look_inside
 def debug_print(space, args_w):
@@ -13,10 +16,12 @@
 debug.debug_print(' '.join(parts))
 
 @jit.dont_look_inside
-@unwrap_spec(category='text')
-def debug_stop(space, category):
-debug.debug_stop(category)
-
+@unwrap_spec(category='text', timestamp=bool)
+def debug_stop(space, category, timestamp=False):
+res = debug.debug_stop(category, timestamp=timestamp)
+if timestamp:
+return space.newint(res)
+return space.w_None
 
 @unwrap_spec(category='text')
 def debug_print_once(space, category, args_w):
diff --git a/pypy/module/__pypy__/test/test_debug.py 
b/pypy/module/__pypy__/test/test_debug.py
--- a/pypy/module/__pypy__/test/test_debug.py
+++ b/pypy/module/__pypy__/test/test_debug.py
@@ -59,3 +59,15 @@
 from __pypy__ import debug_get_timestamp_unit
 unit = debug_get_timestamp_unit()
 assert unit in ('tsc', 'ns', 'QueryPerformanceCounter')
+
+def test_debug_start_stop_timestamp(self):
+import time
+from __pypy__ import debug_start, debug_stop, debug_read_timestamp
+assert debug_start('foo') is None
+assert debug_stop('foo') is None
+ts1 = debug_start('foo', timestamp=True)
+t = time.time()
+while time.time() - t < 0.02:
+pass
+ts2 = debug_stop('foo', timestamp=True)
+assert ts2 > ts1
diff --git a/pypy/module/gc/hook.py b/pypy/module/gc/hook.py
--- a/pypy/module/gc/hook.py
+++ b/pypy/module/gc/hook.py
@@ -1,7 +1,7 @@
 from rpython.memory.gc.hook import GcHooks
 from rpython.memory.gc import incminimark 
 from rpython.rlib.nonconst import NonConstant
-from rpython.rlib.rarithmetic import r_uint, r_longlong
+from rpython.rlib.rarithmetic import r_uint, r_longlong, longlongmax
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef, interp_attrproperty, 
GetSetProperty
@@ -35,6 +35,8 @@
 action = self.w_hooks.gc_minor
 action.count += 1
 action.duration += duration
+action.duration_min = min(action.duration_min, duration)
+action.duration_max = max(action.duration_max, duration)
 action.total_memory_used = total_memory_used
 action.pinned_objects = pinned_objects
 action.fire()
@@ -43,6 +45,8 @@
 action = self.w_hooks.gc_collect_step
 action.count += 1
 action.duration += duration
+action.duration_min = min(action.duration_min, duration)
+action.duration_max = max(action.duration_max, duration)
 action.oldstate = oldstate
 action.newstate = newstate
 action.fire()
@@ -112,18 +116,19 @@
 
 
 class GcMinorHookAction(AsyncAction):
-count = 0
-duration = r_longlong(0)
 total_memory_used = 0
 pinned_objects = 0
 
 def __init__(self, space):
 AsyncAction.__init__(self, space)
 self.w_callable = space.w_None
+self.reset()
 
 def reset(self):
 self.count = 0
 self.duration = r_longlong(0)
+ 

[pypy-commit] pypy py3.5: merge default into py3.5

2018-04-17 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94364:5a7eeaf512fc
Date: 2018-04-18 01:00 +0300
http://bitbucket.org/pypy/pypy/changeset/5a7eeaf512fc/

Log:merge default into py3.5

diff --git a/pypy/module/_cffi_backend/ctypearray.py 
b/pypy/module/_cffi_backend/ctypearray.py
--- a/pypy/module/_cffi_backend/ctypearray.py
+++ b/pypy/module/_cffi_backend/ctypearray.py
@@ -70,7 +70,15 @@
 length = wchar_helper.unicode_size_as_char32(u)
 return (w_value, length + 1)
 else:
-explicitlength = space.getindex_w(w_value, space.w_OverflowError)
+try:
+explicitlength = space.getindex_w(w_value,
+  space.w_OverflowError)
+except OperationError as e:
+if e.match(space, space.w_TypeError):
+raise oefmt(space.w_TypeError,
+"expected new array length or list/tuple/str, "
+"not %T", w_value)
+raise
 if explicitlength < 0:
 raise oefmt(space.w_ValueError, "negative array length")
 return (space.w_None, explicitlength)
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
@@ -278,6 +278,9 @@
 assert repr(q).startswith("https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-04-14 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94333:599b7470b778
Date: 2018-04-15 08:48 +0300
http://bitbucket.org/pypy/pypy/changeset/599b7470b778/

Log:merge default into py3.5

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -6,3 +6,7 @@
 .. startrev: f22145c34985
 
 
+.. branch: issue2752
+
+Fix a rare GC bug that was introduced more than one year ago, but was
+not diagnosed before issue #2752.
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -731,14 +731,16 @@
 
 def move_out_of_nursery(self, obj):
 # called twice, it should return the same shadow object,
-# and not creating another shadow object
-if self.header(obj).tid & GCFLAG_HAS_SHADOW:
-shadow = self.nursery_objects_shadows.get(obj)
-ll_assert(shadow != llmemory.NULL,
-  "GCFLAG_HAS_SHADOW but no shadow found")
-return shadow
-
-return self._allocate_shadow(obj, copy=True)
+# and not creating another shadow object.  As a safety feature,
+# when called on a non-nursery object, do nothing.
+if not self.is_in_nursery(obj):
+return obj
+shadow = self._find_shadow(obj)
+if (self.header(obj).tid & GCFLAG_SHADOW_INITIALIZED) == 0:
+self.header(obj).tid |= GCFLAG_SHADOW_INITIALIZED
+totalsize = self.get_size(obj)
+llmemory.raw_memcopy(obj, shadow, totalsize)
+return shadow
 
 def collect(self, gen=2):
 """Do a minor (gen=0), start a major (gen=1), or do a full
@@ -2074,13 +2076,12 @@
 ll_assert(newobj != llmemory.NULL, "GCFLAG_HAS_SHADOW but no 
shadow found")
 newhdr = newobj - size_gc_header
 #
-# Remove the flag GCFLAG_HAS_SHADOW, so that it doesn't get
-# copied to the shadow itself.
-self.header(obj).tid &= ~GCFLAG_HAS_SHADOW
+# The flags GCFLAG_HAS_SHADOW and GCFLAG_SHADOW_INITIALIZED
+# have no meaning in non-nursery objects.  We don't need to
+# remove them explicitly here before doing the copy.
 tid = self.header(obj).tid
 if (tid & GCFLAG_SHADOW_INITIALIZED) != 0:
 copy = False
-self.header(obj).tid &= ~GCFLAG_SHADOW_INITIALIZED
 #
 totalsize = size_gc_header + self.get_size(obj)
 self.nursery_surviving_size += raw_malloc_usage(totalsize)
@@ -2644,8 +2645,7 @@
 # --
 # id() and identityhash() support
 
-@specialize.arg(2)
-def _allocate_shadow(self, obj, copy=False):
+def _allocate_shadow(self, obj):
 size_gc_header = self.gcheaderbuilder.size_gc_header
 size = self.get_size(obj)
 shadowhdr = self._malloc_out_of_nursery(size_gc_header +
@@ -2667,12 +2667,6 @@
 #
 self.header(obj).tid |= GCFLAG_HAS_SHADOW
 self.nursery_objects_shadows.setitem(obj, shadow)
-
-if copy:
-self.header(obj).tid |= GCFLAG_SHADOW_INITIALIZED
-totalsize = size_gc_header + self.get_size(obj)
-llmemory.raw_memcopy(obj - size_gc_header, shadow, totalsize)
-
 return shadow
 
 def _find_shadow(self, obj):
diff --git a/rpython/memory/gc/test/test_direct.py 
b/rpython/memory/gc/test/test_direct.py
--- a/rpython/memory/gc/test/test_direct.py
+++ b/rpython/memory/gc/test/test_direct.py
@@ -671,6 +671,25 @@
 self.gc.debug_gc_step_until(incminimark.STATE_SCANNING)
 assert self.stackroots[1].x == 13
 
+def test_move_out_of_nursery(self):
+obj0 = self.malloc(S)
+obj0.x = 123
+adr1 = self.gc.move_out_of_nursery(llmemory.cast_ptr_to_adr(obj0))
+obj1 = llmemory.cast_adr_to_ptr(adr1, lltype.Ptr(S))
+assert obj1.x == 123
+#
+import pytest
+obj2 = self.malloc(S)
+obj2.x = 456
+adr3 = self.gc._find_shadow(llmemory.cast_ptr_to_adr(obj2))
+obj3 = llmemory.cast_adr_to_ptr(adr3, lltype.Ptr(S))
+with pytest.raises(lltype.UninitializedMemoryAccess):
+obj3.x # the shadow is not populated yet
+adr4 = self.gc.move_out_of_nursery(llmemory.cast_ptr_to_adr(obj2))
+assert adr4 == adr3
+assert obj3.x == 456 # it is populated now
+
+
 class TestIncrementalMiniMarkGCFull(DirectGCTest):
 from rpython.memory.gc.incminimark import IncrementalMiniMarkGC as GCClass
 def test_malloc_fixedsize_no_cleanup(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-04-14 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94324:1be242f4be56
Date: 2018-04-14 20:47 +0300
http://bitbucket.org/pypy/pypy/changeset/1be242f4be56/

Log:merge default into py3.5

diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -40,6 +40,8 @@
   sure things are ported back to the trunk and to the branch as
   necessary.
 
+* Make sure the RPython builds on the buildbot pass with no failures
+
 * Maybe bump the SOABI number in module/imp/importing. This has many
   implications, so make sure the PyPy community agrees to the change.
 
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -3,16 +3,6 @@
 ==
 
 .. this is a revision shortly after release-pypy-6.0.0
-.. startrev: 2e04adf1b89f
+.. startrev: f22145c34985
 
-.. branch: cpyext-subclass-setattr
 
-Fix for python-level classes that inherit from C-API types, previously the
-`w_obj` was not necessarily preserved throughout the lifetime of the `pyobj`
-which led to cases where instance attributes were lost. Fixes issue #2793
-
-
-.. branch: pyparser-improvements-2
-
-Improve line offsets that are reported by SyntaxError. Improve error messages
-for a few situations, including mismatched parenthesis.
diff --git a/pypy/doc/whatsnew-pypy2-6.0.0.rst 
b/pypy/doc/whatsnew-pypy2-6.0.0.rst
--- a/pypy/doc/whatsnew-pypy2-6.0.0.rst
+++ b/pypy/doc/whatsnew-pypy2-6.0.0.rst
@@ -101,3 +101,15 @@
 Work around possible bugs in upstream ioctl users, like CPython allocate at
 least 1024 bytes for the arg in calls to ``ioctl(fd, request, arg)``. Fixes
 issue #2776
+
+.. branch: cpyext-subclass-setattr
+
+Fix for python-level classes that inherit from C-API types, previously the
+`w_obj` was not necessarily preserved throughout the lifetime of the `pyobj`
+which led to cases where instance attributes were lost. Fixes issue #2793
+
+
+.. branch: pyparser-improvements-2
+
+Improve line offsets that are reported by SyntaxError. Improve error messages
+for a few situations, including mismatched parenthesis.
diff --git a/pypy/module/cpyext/setobject.py b/pypy/module/cpyext/setobject.py
--- a/pypy/module/cpyext/setobject.py
+++ b/pypy/module/cpyext/setobject.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.error import oefmt
+from pypy.interpreter.error import OperationError, oefmt
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (cpython_api, Py_ssize_t, CANNOT_FAIL,
 build_type_checkers)
@@ -64,8 +64,13 @@
 instance of set or its subtype."""
 if not PySet_Check(space, w_s):
 PyErr_BadInternalCall(space)
-space.call_method(space.w_set, 'discard', w_s, w_obj)
-return 0
+try:
+space.call_method(space.w_set, 'remove', w_s, w_obj)
+except OperationError as e:
+if e.match(space, space.w_KeyError):
+return 0
+raise
+return 1
 
 
 @cpython_api([PyObject], PyObject)
diff --git a/pypy/module/cpyext/test/test_setobject.py 
b/pypy/module/cpyext/test/test_setobject.py
--- a/pypy/module/cpyext/test/test_setobject.py
+++ b/pypy/module/cpyext/test/test_setobject.py
@@ -28,7 +28,11 @@
 assert api.PySet_Size(w_set) == 4
 api.PySet_Add(w_set, space.wrap(6))
 assert api.PySet_Size(w_set) == 5
-api.PySet_Discard(w_set, space.wrap(6))
+res = api.PySet_Discard(w_set, space.wrap(6))
+assert res == 1
+assert api.PySet_Size(w_set) == 4
+res = api.PySet_Discard(w_set, space.wrap(6))
+assert res == 0
 assert api.PySet_Size(w_set) == 4
 
 def test_set_contains(self, space, api):
diff --git a/pypy/tool/release/force-builds.py 
b/pypy/tool/release/force-builds.py
--- a/pypy/tool/release/force-builds.py
+++ b/pypy/tool/release/force-builds.py
@@ -31,6 +31,9 @@
 'pypy-c-jit-linux-s390x',
 'build-pypy-c-jit-linux-armhf-raspbian',
 'build-pypy-c-jit-linux-armel',
+'rpython-linux-x86-32',
+'rpython-linux-x86-64'
+'rpython-win-x86-32'
 ]
 
 def get_user():
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -644,7 +644,10 @@
 def get_rpy_type_index(gcref):
 from rpython.rlib.rarithmetic import intmask
 Class = gcref._x.__class__
-return intmask(id(Class))
+i = intmask(id(Class))
+if i < 0:
+i = ~i# always return a positive number, at least
+return i
 
 def cast_gcref_to_int(gcref):
 # This is meant to be used on cast_instance_to_gcref results.
diff --git a/rpython/rlib/rvmprof/src/shared/_vmprof.c 
b/rpython/rlib/rvmprof/src/shared/_vmprof.c
--- a/rpython/rlib/rvmprof/src/shared/_vmprof.c
+++ b/rpython/rlib/rvmprof/src/shared/_vmprof.c
@@ -36,6 +36,8 @@
 register PY_STACK_FRAME_T * callee_saved asm("rbx");
 #elif defined(X86_32)
 register PY_STACK_FRAME_T * calle

[pypy-commit] pypy py3.5: merge default into branch

2018-04-10 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94307:e6d85e030f12
Date: 2018-04-11 06:18 +0300
http://bitbucket.org/pypy/pypy/changeset/e6d85e030f12/

Log:merge default into branch

diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -10,89 +10,6 @@
 PyPy.
 
 
-.. _extension-modules:
-
-Extension modules
--
-
-List of extension modules that we support:
-
-* Supported as built-in modules (in :source:`pypy/module/`):
-
-__builtin__
-:doc:`__pypy__ <__pypy__-module>`
-_ast
-_codecs
-_collections
-:doc:`_continuation `
-:doc:`_ffi `
-_hashlib
-_io
-_locale
-_lsprof
-_md5
-:doc:`_minimal_curses `
-_multiprocessing
-_random
-:doc:`_rawffi `
-_sha
-_socket
-_sre
-_ssl
-_warnings
-_weakref
-_winreg
-array
-binascii
-bz2
-cStringIO
-cmath
-`cpyext`_
-crypt
-errno
-exceptions
-fcntl
-gc
-imp
-itertools
-marshal
-math
-mmap
-operator
-parser
-posix
-pyexpat
-select
-signal
-struct
-symbol
-sys
-termios
-thread
-time
-token
-unicodedata
-zipimport
-zlib
-
-  When translated on Windows, a few Unix-only modules are skipped,
-  and the following module is built instead:
-
-_winreg
-
-* Supported by being rewritten in pure Python (possibly using ``cffi``):
-  see the :source:`lib_pypy/` directory.  Examples of modules that we
-  support this way: ``ctypes``, ``cPickle``, ``cmath``, ``dbm``, 
``datetime``...
-  Note that some modules are both in there and in the list above;
-  by default, the built-in module is used (but can be disabled
-  at translation time).
-
-The extension modules (i.e. modules written in C, in the standard CPython)
-that are neither mentioned above nor in :source:`lib_pypy/` are not available 
in PyPy.
-(You may have a chance to use them anyway with `cpyext`_.)
-
-.. _cpyext: 
http://morepypy.blogspot.com/2010/04/using-cpython-extension-modules-with.html
-
 
 Differences related to garbage collection strategies
 
@@ -572,7 +489,96 @@
   environment variable. CPython searches for ``vcvarsall.bat`` somewhere 
**above**
   that value.
 
+* SyntaxError_ s try harder to give details about the cause of the failure, so
+  the error messages are not the same as in CPython
+
+
+.. _extension-modules:
+
+Extension modules
+-
+
+List of extension modules that we support:
+
+* Supported as built-in modules (in :source:`pypy/module/`):
+
+__builtin__
+:doc:`__pypy__ <__pypy__-module>`
+_ast
+_codecs
+_collections
+:doc:`_continuation `
+:doc:`_ffi `
+_hashlib
+_io
+_locale
+_lsprof
+_md5
+:doc:`_minimal_curses `
+_multiprocessing
+_random
+:doc:`_rawffi `
+_sha
+_socket
+_sre
+_ssl
+_warnings
+_weakref
+_winreg
+array
+binascii
+bz2
+cStringIO
+cmath
+`cpyext`_
+crypt
+errno
+exceptions
+fcntl
+gc
+imp
+itertools
+marshal
+math
+mmap
+operator
+parser
+posix
+pyexpat
+select
+signal
+struct
+symbol
+sys
+termios
+thread
+time
+token
+unicodedata
+zipimport
+zlib
+
+  When translated on Windows, a few Unix-only modules are skipped,
+  and the following module is built instead:
+
+_winreg
+
+* Supported by being rewritten in pure Python (possibly using ``cffi``):
+  see the :source:`lib_pypy/` directory.  Examples of modules that we
+  support this way: ``ctypes``, ``cPickle``, ``cmath``, ``dbm``, 
``datetime``...
+  Note that some modules are both in there and in the list above;
+  by default, the built-in module is used (but can be disabled
+  at translation time).
+
+The extension modules (i.e. modules written in C, in the standard CPython)
+that are neither mentioned above nor in :source:`lib_pypy/` are not available 
in PyPy.
+(You may have a chance to use them anyway with `cpyext`_.)
+
+.. _cpyext: 
http://morepypy.blogspot.com/2010/04/using-cpython-extension-modules-with.html
+
+
 .. _`is ignored in PyPy`: http://bugs.python.org/issue14621
 .. _`little point`: 
http://events.ccc.de/congress/2012/Fahrplan/events/5152.en.html
 .. _`#2072`: https://bitbucket.org/pypy/pypy/issue/2072/
 .. _`issue #2653`: https://bitbucket.org/pypy/pypy/issues/2653/
+.. _SyntaxError: 
https://morepypy.blogspot.co.il/2018/04/improving-syntaxerror-in-pypy.html
diff --git a/pypy/doc/release-v6.0.0.rst b/pypy/doc/release-v6.0.0.rst
--- a/pypy/doc/release-v6.0.0.rst
+++ b/pypy/doc/release-v6.0.0.rst
@@ -14,10 +14,14 @@
 affect the included python development header files, all c-extension modules 
must
 be recompiled for this version.
 
+First-time python users are often stumped by silly typos and emis

[pypy-commit] pypy py3.5: merge default

2018-04-10 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r94295:3d2434de5907
Date: 2018-04-10 10:36 +0200
http://bitbucket.org/pypy/pypy/changeset/3d2434de5907/

Log:merge default

diff --git a/lib-python/2.7/test/test_eof.py b/lib-python/2.7/test/test_eof.py
--- a/lib-python/2.7/test/test_eof.py
+++ b/lib-python/2.7/test/test_eof.py
@@ -5,7 +5,7 @@
 
 class EOFTestCase(unittest.TestCase):
 def test_EOFC(self):
-expect = "EOL while scanning string literal (, line 1)"
+expect = "end of line (EOL) while scanning string literal (, 
line 1)"
 try:
 eval("""'this is a test\
 """)
@@ -15,7 +15,7 @@
 raise test_support.TestFailed
 
 def test_EOFS(self):
-expect = ("EOF while scanning triple-quoted string literal "
+expect = ("end of file (EOF) while scanning triple-quoted string 
literal "
   "(, line 1)")
 try:
 eval("""'''this is a test""")
diff --git a/lib-python/2.7/test/test_traceback.py 
b/lib-python/2.7/test/test_traceback.py
--- a/lib-python/2.7/test/test_traceback.py
+++ b/lib-python/2.7/test/test_traceback.py
@@ -123,10 +123,7 @@
 self.assertEqual(len(err), 4)
 self.assertEqual(err[1].strip(), "print(2)")
 self.assertIn("^", err[2])
-if check_impl_detail():
-self.assertEqual(err[1].find("p"), err[2].find("^"))
-if check_impl_detail(pypy=True):
-self.assertEqual(err[1].find("2)") + 1, err[2].find("^"))
+self.assertEqual(err[1].find("p"), err[2].find("^"))
 
 def test_base_exception(self):
 # Test that exceptions derived from BaseException are formatted right
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -10,3 +10,9 @@
 Fix for python-level classes that inherit from C-API types, previously the
 `w_obj` was not necessarily preserved throughout the lifetime of the `pyobj`
 which led to cases where instance attributes were lost. Fixes issue #2793
+
+
+.. branch: pyparser-improvements-2
+
+Improve line offsets that are reported by SyntaxError. Improve error messages
+for a few situations, including mismatched parenthesis.
diff --git a/pypy/interpreter/pyparser/error.py 
b/pypy/interpreter/pyparser/error.py
--- a/pypy/interpreter/pyparser/error.py
+++ b/pypy/interpreter/pyparser/error.py
@@ -6,6 +6,7 @@
  lastlineno=0):
 self.msg = msg
 self.lineno = lineno
+# NB: offset is a 1-based index!
 self.offset = offset
 self.text = text
 self.filename = filename
diff --git a/pypy/interpreter/pyparser/parser.py 
b/pypy/interpreter/pyparser/parser.py
--- a/pypy/interpreter/pyparser/parser.py
+++ b/pypy/interpreter/pyparser/parser.py
@@ -199,6 +199,7 @@
 self.token_type = token_type
 self.value = value
 self.lineno = lineno
+# this is a 0-based index
 self.column = column
 self.line = line
 self.expected = expected
diff --git a/pypy/interpreter/pyparser/pyparse.py 
b/pypy/interpreter/pyparser/pyparse.py
--- a/pypy/interpreter/pyparser/pyparse.py
+++ b/pypy/interpreter/pyparser/pyparse.py
@@ -232,7 +232,9 @@
 if e.expected_str is not None:
 msg += " (expected '%s')" % e.expected_str
 
-raise new_err(msg, e.lineno, e.column, e.line,
+# parser.ParseError(...).column is 0-based, but the offsets in 
the
+# exceptions in the error module are 1-based, hence the '+ 1'
+raise new_err(msg, e.lineno, e.column + 1, e.line,
   compile_info.filename)
 else:
 tree = self.root
diff --git a/pypy/interpreter/pyparser/pytokenizer.py 
b/pypy/interpreter/pyparser/pytokenizer.py
--- a/pypy/interpreter/pyparser/pytokenizer.py
+++ b/pypy/interpreter/pyparser/pytokenizer.py
@@ -110,7 +110,7 @@
 logical line; continuation lines are included.
 """
 token_list = []
-lnum = parenlev = continued = 0
+lnum = continued = 0
 namechars = NAMECHARS
 numchars = NUMCHARS
 contstr, needcont = '', 0
@@ -118,7 +118,7 @@
 indents = [0]
 altindents = [0]
 last_comment = ''
-parenlevstart = (0, 0, "")
+parenstack = []
 async_def = False
 async_def_nl = False
 async_def_indent = 0
@@ -138,7 +138,7 @@
 if contstr:
 if not line:
 raise TokenError(
-"EOF while scanning triple-quoted string literal",
+"end of file (EOF) while scanning triple-quoted string 
literal",
 strstart[2], strstart[0], strstart[1]+1,
 token_list, lnum-1)
 endmatch = endDFA.recognize(line)
@@ -164,7 +164,7 @@
 contline = contline + line
 continue
 
-elif parenlev == 0 and not continued

[pypy-commit] pypy py3.5: merge default into py3.5

2018-04-09 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94285:e3384cb52177
Date: 2018-04-10 00:30 +0300
http://bitbucket.org/pypy/pypy/changeset/e3384cb52177/

Log:merge default into py3.5

diff --git a/pypy/doc/release-v6.0.0.rst b/pypy/doc/release-v6.0.0.rst
--- a/pypy/doc/release-v6.0.0.rst
+++ b/pypy/doc/release-v6.0.0.rst
@@ -8,26 +8,26 @@
 the dual release.
 
 This release is a feature release following our previous 5.10 incremental
-release in late December 2017, with many improvements in the C-API
-compatability layer and other improvements in speed and CPython compatibility.
-Since the changes affect the included python development header files, all
-c-extension modules must be recompiled for this version.
+release in late December 2017. Our C-API compatability layer ``cpyext`` is
+now much faster (see the `blog post`_) as well as more complete. We have made
+many other improvements in speed and CPython compatibility. Since the changes
+affect the included python development header files, all c-extension modules 
must
+be recompiled for this version.
 
-The Windows PyPy3.5 release is still considered beta-quality. There are issues
-with unicode handling especially around system calls and c-extensions.
+The Windows PyPy3.5 release is still considered beta-quality. There are open
+issues with unicode handling especially around system calls and c-extensions.
 
-The Matplotlib TkAgg backend now works with PyPy. PyGame and pygtk also now can
-work with PyPy.
+The Matplotlib TkAgg backend now works with PyPy, as do pygame and pygobject.
 
 As always, this release is 100% compatible with the previous one and fixed
 several issues and bugs raised by the growing community of PyPy users.
 We strongly recommend updating.
 
+We updated the cffi module included in PyPy to version 1.11.5
+
 The utf8 branch that changes internal representation of unicode to utf8 did not
-make it into the release. We also began working on a Python3.6 implementation,
-help is welcome.
-
-We updated the cffi module included in PyPy to version 1.11.5
+make it into the release, so there is still more goodness coming. We also
+began working on a Python3.6 implementation, help is welcome.
 
 You can download the v6.0 releases here:
 
@@ -46,6 +46,7 @@
 .. _`RPython`: https://rpython.readthedocs.org
 .. _`modules`: project-ideas.html#make-more-python-modules-pypy-friendly
 .. _`help`: project-ideas.html
+.. _`blog post`: 
https://morepypy.blogspot.it/2017/10/cape-of-good-hope-for-pypy-hello-from.html
 
 What is PyPy?
 =
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -5,4 +5,8 @@
 .. this is a revision shortly after release-pypy-6.0.0
 .. startrev: 2e04adf1b89f
 
+.. branch: cpyext-subclass-setattr
 
+Fix for python-level classes that inherit from C-API types, previously the
+`w_obj` was not necessarily preserved throughout the lifetime of the `pyobj`
+which led to cases where instance attributes were lost. Fixes issue #2793
diff --git a/pypy/interpreter/test/test_typedef.py 
b/pypy/interpreter/test/test_typedef.py
--- a/pypy/interpreter/test/test_typedef.py
+++ b/pypy/interpreter/test/test_typedef.py
@@ -423,3 +423,10 @@
 def test_get_with_none_arg(self):
 raises(TypeError, type.__dict__['__mro__'].__get__, None)
 raises(TypeError, type.__dict__['__mro__'].__get__, None, None)
+
+def test_builtin_readonly_property(self):
+import sys
+x = lambda: 5
+e = raises(AttributeError, 'x.func_globals = {}')
+if '__pypy__' in sys.builtin_module_names:
+assert str(e.value) == "readonly attribute 'func_globals'"
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -313,12 +313,18 @@
 self.reqcls, Arguments(space, [w_obj,
space.newtext(self.name)]))
 
+def readonly_attribute(self, space):   # overwritten in cpyext
+if self.name == '':
+raise oefmt(space.w_AttributeError, "readonly attribute")
+else:
+raise oefmt(space.w_AttributeError, "readonly attribute '%s'", 
self.name)
+
 def descr_property_set(self, space, w_obj, w_value):
 """property.__set__(obj, value)
 Change the value of the property of the given obj."""
 fset = self.fset
 if fset is None:
-raise oefmt(space.w_AttributeError, "readonly attribute")
+raise self.readonly_attribute(space)
 try:
 fset(self, space, w_obj, w_value)
 except DescrMismatch:
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -60,10 +60,10 @@
 
 def _cpyext_attach_pyobj(self, space, py_obj):
 self._cpy_ref = py_obj
-rawrefcount.create_link_pyobj(s

[pypy-commit] pypy py3.5: merge default into branch

2018-04-05 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94245:bcbefe2f5e14
Date: 2018-04-05 13:51 +0300
http://bitbucket.org/pypy/pypy/changeset/bcbefe2f5e14/

Log:merge default into branch

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -6,36 +6,36 @@
 Except when otherwise stated (look for LICENSE files in directories or
 information at the beginning of each file) all software and documentation in
 the 'rpython', 'pypy', 'ctype_configure', 'dotviewer', 'demo', 'lib_pypy',
-'py', and '_pytest' directories is licensed as follows: 
+'py', and '_pytest' directories is licensed as follows:
 
 The MIT License
 
-Permission is hereby granted, free of charge, to any person 
-obtaining a copy of this software and associated documentation 
-files (the "Software"), to deal in the Software without 
-restriction, including without limitation the rights to use, 
-copy, modify, merge, publish, distribute, sublicense, and/or 
-sell copies of the Software, and to permit persons to whom the 
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following conditions:
 
-The above copyright notice and this permission notice shall be included 
+The above copyright notice and this permission notice shall be included
 in all copies or substantial portions of the Software.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 DEALINGS IN THE SOFTWARE.
 
 
 PyPy Copyright holders 2003-2018
 
+
 
 Except when otherwise stated (look for LICENSE files or information at
 the beginning of each file) the files in the 'pypy' directory are each
-copyrighted by one or more of the following people and organizations:
+copyrighted by one or more of the following people and organizations:
 
   Armin Rigo
   Maciej Fijalkowski
@@ -89,13 +89,13 @@
   Niko Matsakis
   Alexander Hesse
   Ludovic Aubry
+  stian
   Jacob Hallen
   Jason Creighton
   Mark Young
   Alex Martelli
   Spenser Bauman
   Michal Bendowski
-  stian
   Jan de Mooij
   Tyler Wade
   Vincent Legoll
@@ -123,10 +123,10 @@
   Wenzhu Man
   Konstantin Lopuhin
   John Witulski
+  Jeremy Thurgood
   Greg Price
   Ivan Sichmann Freitas
   Dario Bertini
-  Jeremy Thurgood
   Mark Pearse
   Simon Cross
   Tobias Pape
@@ -145,18 +145,19 @@
   Adrian Kuhn
   tav
   Georg Brandl
+  Joannah Nanjekye
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
   Mike Blume
-  Joannah Nanjekye
   Gerald Klix
   Oscar Nierstrasz
   Rami Chowdhury
   Stefan H. Muller
+  Dodan Mihai
   Tim Felgentreff
   Eugene Oden
-  Dodan Mihai
+  Colin Valliant
   Jeff Terrace
   Henry Mason
   Vasily Kuznetsov
@@ -225,12 +226,14 @@
   Vaibhav Sood
   Reuben Cummings
   Attila Gobi
+  Floris Bruynooghe
   Christopher Pope
   Tristan Arthur
   Christian Tismer 
   Dan Stromberg
   Carl Meyer
   Florin Papa
+  Arianna Avanzini
   Jens-Uwe Mager
   Valentina Mukhamedzhanova
   Stefano Parmesan
@@ -250,9 +253,11 @@
   Alejandro J. Cura
   Vladimir Kryachko
   Gabriel
+  Thomas Hisch
   Mark Williams
   Kunal Grover
   Nathan Taylor
+  Barry Hart
   Travis Francis Athougies
   Yasir Suhail
   Sergey Kishchenko
@@ -260,6 +265,7 @@
   Lutz Paelike
   Ian Foote
   Philipp Rustemeuer
+  Logan Chien
   Catalin Gabriel Manciu
   Jacob Oscarson
   Ryan Gonzalez
@@ -295,7 +301,6 @@
   Akira Li
   Gustavo Niemeyer
   Rafał Gałczyński
-  Logan Chien
   Lucas Stadler
   roberto@goyle
   Matt Bogosian
@@ -308,6 +313,7 @@
   Anna Katrina Dominguez
   Kim Jin Su
   Amber Brown
+  Miro Hrončok
   Anthony Sottile
   Nate Bragg
   Ben Darnell
@@ -315,7 +321,6 @@
   Godefroid Chappelle
   Julian Berman
   Michael Hudson-Doyle
-  Floris Bruynooghe
   Step

[pypy-commit] pypy py3.5: merge default into branch

2018-04-04 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94232:552c05a134d7
Date: 2018-04-04 19:40 +0300
http://bitbucket.org/pypy/pypy/changeset/552c05a134d7/

Log:merge default into branch

diff --git a/lib-python/2.7/re.py b/lib-python/2.7/re.py
--- a/lib-python/2.7/re.py
+++ b/lib-python/2.7/re.py
@@ -225,7 +225,7 @@
 
 _pattern_type = type(sre_compile.compile("", 0))
 
-_MAXCACHE = 100
+_MAXCACHE = 1000
 
 def _compile(*key):
 # internal: compile pattern
diff --git a/lib-python/2.7/test/test_genexps.py 
b/lib-python/2.7/test/test_genexps.py
--- a/lib-python/2.7/test/test_genexps.py
+++ b/lib-python/2.7/test/test_genexps.py
@@ -87,7 +87,7 @@
 >>> dict(a = i for i in xrange(10))
 Traceback (most recent call last):
...
-SyntaxError: invalid syntax
+SyntaxError: invalid syntax (expected ')')
 
 Verify that parenthesis are required when used as a keyword argument value
 
diff --git a/pypy/doc/whatsnew-6.0.0.rst b/pypy/doc/whatsnew-6.0.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatsnew-6.0.0.rst
@@ -0,0 +1,103 @@
+===
+What's new in PyPy2.7 5.10+
+===
+
+.. this is a revision shortly after release-pypy2.7-v5.10.0
+.. startrev: 6b024edd9d12
+
+.. branch: cpyext-avoid-roundtrip
+
+Big refactoring of some cpyext code, which avoids a lot of nonsense when
+calling C from Python and vice-versa: the result is a big speedup in
+function/method calls, up to 6 times faster.
+
+.. branch: cpyext-datetime2
+
+Support ``tzinfo`` field on C-API datetime objects, fixes latest pandas HEAD
+
+
+.. branch: mapdict-size-limit
+
+Fix a corner case of mapdict: When an instance is used like a dict (using
+``setattr`` and ``getattr``, or ``.__dict__``) and a lot of attributes are
+added, then the performance using mapdict is linear in the number of
+attributes. This is now fixed (by switching to a regular dict after 80
+attributes).
+
+
+.. branch: cpyext-faster-arg-passing
+
+When using cpyext, improve the speed of passing certain objects from PyPy to C
+code, most notably None, True, False, types, all instances of C-defined types.
+Before, a dict lookup was needed every time such an object crossed over, now it
+is just a field read.
+
+
+.. branch: 2634_datetime_timedelta_performance
+
+Improve datetime + timedelta performance.
+
+.. branch: memory-accounting
+
+Improve way to describe memory
+
+.. branch: msvc14
+
+Allow compilaiton with Visual Studio 2017 compiler suite on windows
+
+.. branch: winapi
+
+Update _winapi and internal _winbase_cffi (via _winbase_build) for python 3 
+
+.. branch: refactor-slots
+
+Refactor cpyext slots.
+
+
+.. branch: call-loopinvariant-into-bridges
+
+Speed up branchy code that does a lot of function inlining by saving one call
+to read the TLS in most bridges.
+
+.. branch: rpython-sprint
+
+Refactor in rpython signatures
+
+.. branch: cpyext-tls-operror2
+
+Store error state thread-locally in executioncontext, fixes issue #2764
+
+.. branch: cpyext-fast-typecheck
+
+Optimize `Py*_Check` for `Bool`, `Float`, `Set`. Also refactor and simplify
+`W_PyCWrapperObject` which is used to call slots from the C-API, greatly
+improving microbenchmarks in https://github.com/antocuni/cpyext-benchmarks
+
+
+.. branch: fix-sre-problems
+
+Fix two (unrelated) JIT bugs manifesting in the re module:
+
+- green fields are broken and were thus disabled, plus their usage removed from
+  the _sre implementation
+
+- in rare "trace is too long" situations, the JIT could break behaviour
+  arbitrarily.
+
+.. branch: jit-hooks-can-be-disabled
+
+Be more efficient about JIT hooks. Make it possible for the frontend to declare
+that jit hooks are currently not enabled at all. in that case, the list of ops
+does not have to be created in the case of the on_abort hook (which is
+expensive).
+
+
+.. branch: pyparser-improvements
+
+Improve speed of Python parser, improve ParseError messages slightly.
+
+.. branch: ioctl-arg-size
+
+Work around possible bugs in upstream ioctl users, like CPython allocate at
+least 1024 bytes for the arg in calls to ``ioctl(fd, request, arg)``. Fixes
+issue #2776
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -1,85 +1,8 @@
-===
-What's new in PyPy2.7 5.10+
-===
+==
+What's new in PyPy2.7 6.0+
+==
 
-.. this is a revision shortly after release-pypy2.7-v5.10.0
-.. startrev: 6b024edd9d12
+.. this is a revision shortly after release-pypy-6.0.0
+.. startrev: 2e04adf1b89f
 
-.. branch: cpyext-avoid-roundtrip
 
-Big refactoring of some cpyext code, which avoids a lot of nonsense when
-calling C from Python and vice-versa: the result is a big speedup in
-function/method calls, up to 6 times faster.
-
-.. branch: cpyext-datetime2
-
-Support ``tzinfo`` field on C-API datetime objects, fixes latest pandas HEAD
-
-
-.. branch: mapdict-si

[pypy-commit] pypy py3.5: merge default

2018-03-30 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r94179:47bcad155e44
Date: 2018-03-29 20:23 +0200
http://bitbucket.org/pypy/pypy/changeset/47bcad155e44/

Log:merge default

diff --git a/pypy/module/pypyjit/hooks.py b/pypy/module/pypyjit/hooks.py
--- a/pypy/module/pypyjit/hooks.py
+++ b/pypy/module/pypyjit/hooks.py
@@ -7,12 +7,20 @@
 WrappedOp, W_JitLoopInfo, wrap_oplist)
 
 class PyPyJitIface(JitHookInterface):
+def are_hooks_enabled(self):
+space = self.space
+cache = space.fromcache(Cache)
+return (cache.w_compile_hook is not None or
+cache.w_abort_hook is not None or
+cache.w_trace_too_long_hook is not None)
+
+
 def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops, 
operations):
 space = self.space
 cache = space.fromcache(Cache)
 if cache.in_recursion:
 return
-if space.is_true(cache.w_abort_hook):
+if cache.w_abort_hook is not None:
 cache.in_recursion = True
 oplist_w = wrap_oplist(space, logops, operations)
 try:
@@ -33,7 +41,7 @@
 cache = space.fromcache(Cache)
 if cache.in_recursion:
 return
-if space.is_true(cache.w_trace_too_long_hook):
+if cache.w_trace_too_long_hook is not None:
 cache.in_recursion = True
 try:
 try:
@@ -62,7 +70,7 @@
 cache = space.fromcache(Cache)
 if cache.in_recursion:
 return
-if space.is_true(cache.w_compile_hook):
+if cache.w_compile_hook is not None:
 w_debug_info = W_JitLoopInfo(space, debug_info, is_bridge,
  cache.compile_hook_with_ops)
 cache.in_recursion = True
diff --git a/pypy/module/pypyjit/interp_resop.py 
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -21,9 +21,10 @@
 no = 0
 
 def __init__(self, space):
-self.w_compile_hook = space.w_None
-self.w_abort_hook = space.w_None
-self.w_trace_too_long_hook = space.w_None
+self.w_compile_hook = None
+self.w_abort_hook = None
+self.w_trace_too_long_hook = None
+self.compile_hook_with_ops = False
 
 def getno(self):
 self.no += 1
@@ -58,7 +59,8 @@
 jit hook won't be called for that.
 """
 cache = space.fromcache(Cache)
-assert w_hook is not None
+if space.is_w(w_hook, space.w_None):
+w_hook = None
 cache.w_compile_hook = w_hook
 cache.compile_hook_with_ops = bool(operations)
 cache.in_recursion = NonConstant(False)
@@ -77,7 +79,8 @@
 as attributes on JitLoopInfo object.
 """
 cache = space.fromcache(Cache)
-assert w_hook is not None
+if space.is_w(w_hook, space.w_None):
+w_hook = None
 cache.w_abort_hook = w_hook
 cache.in_recursion = NonConstant(False)
 
@@ -92,14 +95,15 @@
 hook(jitdriver_name, greenkey)
 """
 cache = space.fromcache(Cache)
-assert w_hook is not None
+if space.is_w(w_hook, space.w_None):
+w_hook = None
 cache.w_trace_too_long_hook = w_hook
 cache.in_recursion = NonConstant(False)
 
 def wrap_oplist(space, logops, operations, ops_offset=None):
 # this function is called from the JIT
 from rpython.jit.metainterp.resoperation import rop
-
+
 l_w = []
 jitdrivers_sd = logops.metainterp_sd.jitdrivers_sd
 for op in operations:
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py 
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -86,18 +86,22 @@
 
 def interp_on_compile():
 di_loop.oplist = cls.oplist
-pypy_hooks.after_compile(di_loop)
+if pypy_hooks.are_hooks_enabled():
+pypy_hooks.after_compile(di_loop)
 
 def interp_on_compile_bridge():
-pypy_hooks.after_compile_bridge(di_bridge)
+if pypy_hooks.are_hooks_enabled():
+pypy_hooks.after_compile_bridge(di_bridge)
 
 def interp_on_optimize():
-di_loop_optimize.oplist = cls.oplist
-pypy_hooks.before_compile(di_loop_optimize)
+if pypy_hooks.are_hooks_enabled():
+di_loop_optimize.oplist = cls.oplist
+pypy_hooks.before_compile(di_loop_optimize)
 
 def interp_on_abort():
-pypy_hooks.on_abort(Counters.ABORT_TOO_LONG, pypyjitdriver,
-greenkey, 'blah', Logger(MockSD), [])
+if pypy_hooks.are_hooks_enabled():
+pypy_hooks.on_abort(Counters.ABORT_TOO_LONG, pypyjitdriver,
+greenkey, 'blah', Logger(MockSD), [])
 
 space = cls.space
 cls.w_on_compile = space.wrap(interp2app(interp_on_compile))
diff --git a

[pypy-commit] pypy py3.5: merge default

2018-03-29 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r94170:ffbcc29df485
Date: 2018-03-29 12:03 +0200
http://bitbucket.org/pypy/pypy/changeset/ffbcc29df485/

Log:merge default

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -72,3 +72,14 @@
 Optimize `Py*_Check` for `Bool`, `Float`, `Set`. Also refactor and simplify
 `W_PyCWrapperObject` which is used to call slots from the C-API, greatly
 improving microbenchmarks in https://github.com/antocuni/cpyext-benchmarks
+
+
+.. branch: fix-sre-problems
+
+Fix two (unrelated) JIT bugs manifesting in the re module:
+
+- green fields are broken and were thus disabled, plus their usage removed from
+  the _sre implementation
+
+- in rare "trace is too long" situations, the JIT could break behaviour
+  arbitrarily.
diff --git a/pypy/module/_cffi_backend/ccallback.py 
b/pypy/module/_cffi_backend/ccallback.py
--- a/pypy/module/_cffi_backend/ccallback.py
+++ b/pypy/module/_cffi_backend/ccallback.py
@@ -232,7 +232,9 @@
 "different from the 'ffi.h' file seen at compile-time)")
 
 def py_invoke(self, ll_res, ll_args):
+key_pycode = self.key_pycode
 jitdriver1.jit_merge_point(callback=self,
+   key_pycode=key_pycode,
ll_res=ll_res,
ll_args=ll_args)
 self.do_invoke(ll_res, ll_args)
@@ -294,7 +296,7 @@
 return 'cffi_callback ' + key_pycode.get_repr()
 
 jitdriver1 = jit.JitDriver(name='cffi_callback',
-   greens=['callback.key_pycode'],
+   greens=['key_pycode'],
reds=['ll_res', 'll_args', 'callback'],
get_printable_location=get_printable_location1)
 
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -76,15 +76,15 @@
 w_import = space.getattr(space.builtin, space.newtext("__import__"))
 return space.call_function(w_import, space.newtext("re"))
 
-def matchcontext(space, ctx):
+def matchcontext(space, ctx, pattern):
 try:
-return rsre_core.match_context(ctx)
+return rsre_core.match_context(ctx, pattern)
 except rsre_core.Error as e:
 raise OperationError(space.w_RuntimeError, space.newtext(e.msg))
 
-def searchcontext(space, ctx):
+def searchcontext(space, ctx, pattern):
 try:
-return rsre_core.search_context(ctx)
+return rsre_core.search_context(ctx, pattern)
 except rsre_core.Error as e:
 raise OperationError(space.w_RuntimeError, space.newtext(e.msg))
 
@@ -189,7 +189,7 @@
 raise oefmt(space.w_TypeError,
 "can't use a bytes pattern on a string-like "
 "object")
-return rsre_core.UnicodeMatchContext(self.code, unicodestr,
+return rsre_core.UnicodeMatchContext(unicodestr,
  pos, endpos, flags)
 else:
 if self.is_known_unicode():
@@ -197,10 +197,10 @@
 "can't use a string pattern on a bytes-like "
 "object")
 if string is not None:
-return rsre_core.StrMatchContext(self.code, string,
+return rsre_core.StrMatchContext(string,
  pos, endpos, flags)
 else:
-return rsre_core.BufMatchContext(self.code, buf,
+return rsre_core.BufMatchContext(buf,
  pos, endpos, flags)
 
 def getmatch(self, ctx, found):
@@ -212,18 +212,18 @@
 @unwrap_spec(pos=int, endpos=int)
 def match_w(self, w_string, pos=0, endpos=sys.maxint):
 ctx = self.make_ctx(w_string, pos, endpos)
-return self.getmatch(ctx, matchcontext(self.space, ctx))
+return self.getmatch(ctx, matchcontext(self.space, ctx, self.code))
 
 @unwrap_spec(pos=int, endpos=int)
 def fullmatch_w(self, w_string, pos=0, endpos=sys.maxint):
 ctx = self.make_ctx(w_string, pos, endpos)
 ctx.fullmatch_only = True
-return self.getmatch(ctx, matchcontext(self.space, ctx))
+return self.getmatch(ctx, matchcontext(self.space, ctx, self.code))
 
 @unwrap_spec(pos=int, endpos=int)
 def search_w(self, w_string, pos=0, endpos=sys.maxint):
 ctx = self.make_ctx(w_string, pos, endpos)
-return self.getmatch(ctx, searchcontext(self.space, ctx))
+return self.getmatch(ctx, searchcontext(self.space, ctx, self.code))
 
 @unwrap_spec(pos=int, endpos=int)
 def findall_w(self, w_string, pos=0, endpos=sys.maxint):
@@ -231,7 +231,7 @@
 matchlist_w = []
 ctx = self.make_ctx(w_string, pos, endpos)
 while ctx.match_sta

[pypy-commit] pypy py3.5: merge default into branch

2018-03-29 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94166:c3b4518f2322
Date: 2018-03-29 12:48 +0300
http://bitbucket.org/pypy/pypy/changeset/c3b4518f2322/

Log:merge default into branch

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -62,3 +62,13 @@
 .. branch: rpython-sprint
 
 Refactor in rpython signatures
+
+.. branch: cpyext-tls-operror2
+
+Store error state thread-locally in executioncontext, fixes issue #2764
+
+.. branch: cpyext-fast-typecheck
+
+Optimize `Py*_Check` for `Bool`, `Float`, `Set`. Also refactor and simplify
+`W_PyCWrapperObject` which is used to call slots from the C-API, greatly
+improving microbenchmarks in https://github.com/antocuni/cpyext-benchmarks
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -5,7 +5,8 @@
 from pypy.objspace.std.listobject import (
 ListStrategy, UNROLL_CUTOFF, W_ListObject, ObjectListStrategy)
 from pypy.module.cpyext.api import (
-cpython_api, CANNOT_FAIL, CONST_STRING, Py_ssize_t, PyObject, PyObjectP)
+cpython_api, CANNOT_FAIL, CONST_STRING, Py_ssize_t, PyObject, PyObjectP,
+generic_cpy_call)
 from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref
 from pypy.module.cpyext.pyobject import as_pyobj, incref
 from rpython.rtyper.lltypesystem import rffi, lltype
@@ -145,21 +146,26 @@
 # XXX we should call Py*_GET_ITEM() instead of Py*_GetItem()
 # from here, but we cannot because we are also called from
 # PySequence_GetItem()
+py_obj = as_pyobj(space, w_obj)
 if isinstance(w_obj, tupleobject.W_TupleObject):
 from pypy.module.cpyext.tupleobject import PyTuple_GetItem
-py_obj = as_pyobj(space, w_obj)
 py_res = PyTuple_GetItem(space, py_obj, i)
 incref(space, py_res)
 keepalive_until_here(w_obj)
 return py_res
 if isinstance(w_obj, W_ListObject):
 from pypy.module.cpyext.listobject import PyList_GetItem
-py_obj = as_pyobj(space, w_obj)
 py_res = PyList_GetItem(space, py_obj, i)
 incref(space, py_res)
 keepalive_until_here(w_obj)
 return py_res
-return make_ref(space, space.getitem(w_obj, space.newint(i)))
+
+as_sequence = py_obj.c_ob_type.c_tp_as_sequence
+if not as_sequence or not as_sequence.c_sq_item:
+raise oefmt(space.w_TypeError,
+"'%T' object does not support indexing", w_obj)
+ret = generic_cpy_call(space, as_sequence.c_sq_item, w_obj, i)
+return make_ref(space, ret)
 
 @cpython_api([PyObject, Py_ssize_t], PyObject, result_is_ll=True)
 def PySequence_GetItem(space, w_obj, i):
diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c
--- a/pypy/module/cpyext/test/array.c
+++ b/pypy/module/cpyext/test/array.c
@@ -2638,6 +2638,16 @@
 Py_RETURN_NONE;
 };
 
+static PyObject *
+getitem(PyObject* self, PyObject * args) {
+PyObject * obj;
+int i;
+if (!PyArg_ParseTuple(args, "Oi", &obj, &i)) {
+return NULL;
+}
+return PySequence_ITEM(obj, i);
+}
+
 PyDoc_STRVAR(module_doc,
 "This module defines an object type which can efficiently represent\n\
 an array of basic values: characters, integers, floating point\n\
@@ -2937,6 +2947,7 @@
 {"create_and_release_buffer",   (PyCFunction)create_and_release_buffer, 
METH_O, NULL},
 {"write_buffer_len", write_buffer_len, METH_O, NULL},
 {"same_dealloc",   (PyCFunction)same_dealloc, METH_VARARGS, NULL},
+{"getitem", (PyCFunction)getitem, METH_VARARGS, NULL},
 {NULL, NULL, 0, NULL}/* Sentinel */
 };
 
diff --git a/pypy/module/cpyext/test/test_arraymodule.py 
b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -167,3 +167,15 @@
 fd = BytesIO()
 # only test that it works
 fd.write(a)
+
+def test_getitem_via_PySequence_GetItem(self):
+module = self.import_module(name='array')
+a = module.array('i', range(10))
+# call via tp_as_mapping.mp_subscript
+assert 5 == a[-5]
+# PySequence_ITEM used to call space.getitem() which
+# prefers tp_as_mapping.mp_subscript over tp_as_sequence.sq_item
+# Now fixed so this test raises (array_item does not add len(a),
+# array_subscr does)
+raises(IndexError, module.getitem, a, -5)
+
diff --git a/pypy/module/cpyext/test/test_typeobject.py 
b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -8,6 +8,7 @@
 from pypy.module.cpyext.typeobject import cts, PyTypeObjectPtr
 
 
+
 class AppTestTypeObject(AppTestCpythonExtensionBase):
 
 def setup_class(cls):
@@ -917,6 +918,10 @@
 res = "foo" in obj
 assert res is True
 
+#

[pypy-commit] pypy py3.5: merge default into py3.5

2018-03-26 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r94140:96851b8e1c6a
Date: 2018-03-26 14:29 +0300
http://bitbucket.org/pypy/pypy/changeset/96851b8e1c6a/

Log:merge default into py3.5

diff too long, truncating to 2000 out of 2028 lines

diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -4,42 +4,40 @@
 
 Welcome to PyPy!
 
-PyPy is both an implementation of the Python programming language, and
-an extensive compiler framework for dynamic language implementations.
-You can build self-contained Python implementations which execute
-independently from CPython.
+PyPy is an interperter that implements the Python programming language, based
+on the RPython compiler framework for dynamic language implementations.
 
-The home page is:
+The home page for the interpreter is:
 
 http://pypy.org/
 
-If you want to help developing PyPy, this document might help you:
+If you want to help developing PyPy, this documentation might help you:
 
 http://doc.pypy.org/
 
-It will also point you to the rest of the documentation which is generated
-from files in the pypy/doc directory within the source repositories. Enjoy
-and send us feedback!
+More documentation about the RPython framework can be found here
 
-the pypy-dev team 
+http://rpython.readthedocs.io
 
+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
+download and use PyPy as an alternative to CPython. 
 
 Building
 
 
-First switch to or download the correct branch.  The basic choices are
-``default`` for Python 2.7 and, for Python 3.X, the corresponding py3.X
-branch (e.g. ``py3.5``).
+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
 
-Build with:
+http://doc.pypy.org/en/latest/build.html
 
-.. code-block:: console
+Enjoy and send us feedback!
 
-$ rpython/bin/rpython -Ojit pypy/goal/targetpypystandalone.py
+the pypy-dev team 
 
-This ends up with a ``pypy-c`` or ``pypy3-c`` binary in the main pypy
-directory.  We suggest to use virtualenv with the resulting
-pypy-c/pypy3-c as the interpreter; you can find more details about
-various installation schemes here:
 
-http://doc.pypy.org/en/latest/install.html
diff --git a/pypy/doc/install.rst b/pypy/doc/install.rst
--- a/pypy/doc/install.rst
+++ b/pypy/doc/install.rst
@@ -17,13 +17,18 @@
 ~
 
 The quickest way to start using PyPy is to download a prebuilt binary for your
-OS and architecture.  You can either use the `most recent release`_ or one of
-our `development nightly build`_.  Please note that the nightly builds are not
+OS and architecture.  You may be able to use either use the
+`most recent release`_ or one of our `development nightly build`_. These
+builds depend on dynamically linked libraries that may not be available on your
+OS. See the section about `Linux binaries` for more info and alternatives that
+may work on your system.
+
+Please note that the nightly builds are not
 guaranteed to be as stable as official releases, use them at your own risk.
 
 .. _most recent release: http://pypy.org/download.html
 .. _development nightly build: http://buildbot.pypy.org/nightly/trunk/
-
+.. _Linux binaries: 
http://pypy.org/download.html#linux-binaries-and-common-distributions
 
 Installing PyPy
 ~~~
@@ -69,9 +74,9 @@
 ~~~
 
 It is often convenient to run pypy inside a virtualenv.  To do this
-you need a recent version of virtualenv -- 1.6.1 or greater.  You can
+you need a version of virtualenv -- 1.6.1 or greater.  You can
 then install PyPy both from a precompiled tarball or from a mercurial
-checkout::
+checkout after translation::
 
# from a tarball
$ virtualenv -p /opt/pypy-xxx/bin/pypy my-pypy-env
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -357,12 +357,13 @@
 sublist_w = []
 n = last_pos = 0
 while not count or n < count:
+pattern = ctx.pattern
 sub_jitdriver.jit_merge_point(
 self=self,
 use_builder=use_builder,
 filter_is_callable=filter_is_callable,
 filter_type=type(w_filter),
-ctx=ctx,
+ctx=ctx, pattern=pattern,
 w_filter=w_filter,
 strbuilder=strbuilder,
 unicodebuilder=unicodebuilder,
@@ -437,7 +438,7 @@
 filter_as_unicode
 w_string sublist_w
 self""".split(),
-greens=["filter_is_callable", "use_builder", "filter_type", "ctx.pattern"])
+greens=["filter_is_callable", "use_builder", "filter_type", "pattern"])
 
 
 def _su

[pypy-commit] pypy py3.5: merge default into py3.5

2018-03-09 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93966:66f30ba67227
Date: 2018-03-09 14:58 +0200
http://bitbucket.org/pypy/pypy/changeset/66f30ba67227/

Log:merge default into py3.5

diff --git a/lib_pypy/_pypy_testcapi.py b/lib_pypy/_pypy_testcapi.py
--- a/lib_pypy/_pypy_testcapi.py
+++ b/lib_pypy/_pypy_testcapi.py
@@ -3,7 +3,7 @@
 import importlib.machinery
 
 
-def get_hashed_dir(cfile):
+def _get_hashed_filename(cfile):
 with open(cfile,'r') as fid:
 content = fid.read()
 # from cffi's Verifier()
@@ -23,10 +23,28 @@
 username = os.environ['USERNAME']   #windows
 except KeyError:
 username = os.getuid()
-output_dir = tempfile.gettempdir() + os.path.sep + 'tmp_%s_%s%s' % (
+return tempfile.gettempdir() + os.path.sep + 'testcapi_%s_%s%s' % (
 username, k1, k2)
-if not os.path.exists(output_dir):
+
+def get_hashed_dir(cfile):
+hashed_fn = _get_hashed_filename(cfile)
+try:
+with open(hashed_fn) as f:
+dirname = f.read(1024)
+except IOError:
+dirname = ''
+tmpdir = tempfile.gettempdir()
+if (not dirname or '/' in dirname or '\\' in dirname or '\x00' in dirname
+or not os.path.isdir(os.path.join(tmpdir, dirname))):
+dirname = binascii.hexlify(os.urandom(8))
+if not isinstance(dirname, str):# Python 3
+dirname = dirname.decode('ascii')
+dirname = 'testcapi_' + dirname
+output_dir = os.path.join(tmpdir, dirname)
+try:
 os.mkdir(output_dir)
+except OSError:
+pass
 return output_dir
 
 
@@ -35,13 +53,12 @@
 return suffixes[0] if suffixes else None
 
 
-def compile_shared(csource, modulename, output_dir=None):
+def compile_shared(csource, modulename, output_dir):
 """Compile '_testcapi.c' or '_ctypes_test.c' into an extension module,
 and import it.
 """
 thisdir = os.path.dirname(__file__)
-if output_dir is None:
-output_dir = tempfile.mkdtemp()
+assert output_dir is not None
 
 from distutils.ccompiler import new_compiler
 
@@ -85,4 +102,16 @@
 # Now import the newly created library, it will replace the original
 # module in sys.modules
 fp, filename, description = imp.find_module(modulename, path=[output_dir])
-imp.load_module(modulename, fp, filename, description)
+with fp:
+imp.load_module(modulename, fp, filename, description)
+
+# If everything went fine up to now, write the name of this new
+# directory to 'hashed_fn', for future processes (and to avoid a
+# growing number of temporary directories that are not completely
+# obvious to clean up on Windows)
+hashed_fn = _get_hashed_filename(os.path.join(thisdir, csource))
+try:
+with open(hashed_fn, 'w') as f:
+f.write(os.path.basename(output_dir))
+except IOError:
+pass
diff --git a/pypy/module/_cffi_backend/cdlopen.py 
b/pypy/module/_cffi_backend/cdlopen.py
--- a/pypy/module/_cffi_backend/cdlopen.py
+++ b/pypy/module/_cffi_backend/cdlopen.py
@@ -53,8 +53,7 @@
 self.libhandle = rffi.cast(DLLHANDLE, 0)
 
 if not libhandle:
-raise oefmt(self.ffi.w_FFIError, "library '%s' is already closed",
-self.libname)
+return
 self.may_unregister_rpython_finalizer(self.ffi.space)
 
 # Clear the dict to force further accesses to do cdlopen_fetch()
diff --git a/pypy/module/_cffi_backend/libraryobj.py 
b/pypy/module/_cffi_backend/libraryobj.py
--- a/pypy/module/_cffi_backend/libraryobj.py
+++ b/pypy/module/_cffi_backend/libraryobj.py
@@ -90,7 +90,6 @@
 w_ctype.convert_from_object(rffi.cast(rffi.CCHARP, cdata), w_value)
 
 def close_lib(self):
-self.check_closed()
 self._finalize_()
 
 
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
@@ -398,6 +398,7 @@
 #
 x.close_lib()
 py.test.raises(ValueError, x.load_function, BVoidP, 'sqrt')
+x.close_lib()
 
 def test_no_len_on_nonarray():
 p = new_primitive_type("int")
diff --git a/pypy/module/_cffi_backend/test/test_re_python.py 
b/pypy/module/_cffi_backend/test/test_re_python.py
--- a/pypy/module/_cffi_backend/test/test_re_python.py
+++ b/pypy/module/_cffi_backend/test/test_re_python.py
@@ -114,12 +114,10 @@
 from re_python_pysrc import ffi
 lib = ffi.dlopen(self.extmod)
 ffi.dlclose(lib)
-e = raises(ffi.error, ffi.dlclose, lib)
-assert str(e.value) == (
-"library '%s' is already closed" % (self.extmod,))
 e = raises(ffi.error, getattr, lib, 'add42')
 assert str(e.value) == (
 "library '%s' has been closed" % (self.extmod,))
+ffi.dlclose(lib)   # does not raise
 
 def test_constant_via_lib(self):
 self.fix_path()

[pypy-commit] pypy py3.5: merge default into py3.5

2018-03-01 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93936:bd80880bbcdc
Date: 2018-03-01 16:21 -0800
http://bitbucket.org/pypy/pypy/changeset/bd80880bbcdc/

Log:merge default into py3.5

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default

2018-02-28 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.5
Changeset: r93907:5289cd302dff
Date: 2018-02-28 16:53 +0100
http://bitbucket.org/pypy/pypy/changeset/5289cd302dff/

Log:merge default

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into branch

2018-02-25 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93886:6dcfe4a00bb7
Date: 2018-02-25 20:24 -0500
http://bitbucket.org/pypy/pypy/changeset/6dcfe4a00bb7/

Log:merge default into branch

diff --git a/lib_pypy/_dbm.py b/lib_pypy/_dbm.py
--- a/lib_pypy/_dbm.py
+++ b/lib_pypy/_dbm.py
@@ -168,7 +168,14 @@
 def open(filename, flag='r', mode=0o666):
 "open a DBM database"
 if not isinstance(filename, str):
-raise TypeError("expected string")
+if sys.version_info < (3,) and isinstance(filename, unicode):
+# unlike CPython we'll encode 'filename' with filesystemencoding
+# instead of defaultencoding, because that seems like a far
+# better idea.  But I'm also open for saying that we should
+# rather go for bug-to-bug compatibility instead.
+filename = filename.encode(sys.getfilesystemencoding())
+else:
+raise TypeError("expected string")
 filename = filename.encode(sys.getdefaultencoding())
 
 openflag = 0
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -567,6 +567,11 @@
   versions of PyPy may have to rename the arguments if CPython starts
   accepting them too.
 
+* PyPy3: `distutils` has been enhanced to allow finding `VsDevCmd.bat` in the
+  directory pointed to by the `VS%0.f0COMNTOOLS` (typically `VS140COMNTOOLS`)
+  environment variable. CPython searches for `vcvarsall.bat` somewhere _above_
+  that value.
+
 .. _`is ignored in PyPy`: http://bugs.python.org/issue14621
 .. _`little point`: 
http://events.ccc.de/congress/2012/Fahrplan/events/5152.en.html
 .. _`#2072`: https://bitbucket.org/pypy/pypy/issue/2072/
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -48,3 +48,7 @@
 .. branch: winapi
 
 Update _winapi and internal _winbase_cffi (via _winbase_build) for python 3 
+
+.. branch: refactor-slots
+
+Refactor cpyext slots.
diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py
--- a/pypy/module/_sre/interp_sre.py
+++ b/pypy/module/_sre/interp_sre.py
@@ -385,8 +385,11 @@
 if not (last_pos == ctx.match_start
  == ctx.match_end and n > 0):
 # the above ignores empty matches on latest position
+last_pos = ctx.match_end
 if filter_is_callable:
 w_match = self.getmatch(ctx, True)
+# make a copy of 'ctx'; see test_sub_matches_stay_valid
+ctx = ctx.fresh_copy(start) # match_start/match_end dropped
 w_piece = space.call_function(w_filter, w_match)
 if not space.is_w(w_piece, space.w_None):
 assert strbuilder is None and unicodebuilder is None
@@ -403,7 +406,6 @@
 unicodebuilder.append(filter_as_unicode)
 else:
 sublist_w.append(w_filter)
-last_pos = ctx.match_end
 n += 1
 elif last_pos >= ctx.end:
 break# empty match at the end: finished
diff --git a/pypy/module/_sre/test/test_app_sre.py 
b/pypy/module/_sre/test/test_app_sre.py
--- a/pypy/module/_sre/test/test_app_sre.py
+++ b/pypy/module/_sre/test/test_app_sre.py
@@ -355,6 +355,18 @@
 KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
 raises(TypeError, KEYCRE.sub, "hello", {"%(": 1})
 
+def test_sub_matches_stay_valid(self):
+import re
+matches = []
+def callback(match):
+matches.append(match)
+return "x"
+result = re.compile(r"[ab]").sub(callback, "acb")
+assert result == "xcx"
+assert len(matches) == 2
+assert matches[0].group() == "a"
+assert matches[1].group() == "b"
+
 
 class AppTestSreScanner:
 
diff --git a/pypy/module/test_lib_pypy/test_dbm_extra.py 
b/pypy/module/test_lib_pypy/test_dbm_extra.py
--- a/pypy/module/test_lib_pypy/test_dbm_extra.py
+++ b/pypy/module/test_lib_pypy/test_dbm_extra.py
@@ -1,4 +1,4 @@
-import py
+import py, os
 from rpython.tool.udir import udir
 try:
 from lib_pypy import dbm
@@ -73,3 +73,8 @@
 assert 'key_with_empty_value' in d
 assert d['key_with_empty_value'] == ''
 d.close()
+
+def test_unicode_filename():
+path = str(udir) + os.sep + u'test_dbm_extra.test_unicode_filename'
+d = dbm.open(path, 'c')
+d.close()
diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -354,7 +354,7 @@
 else:
 # this is dead code, but in case we have a gc that does
 # not have a write barrier and does not zero memory, we would
-# need to clal it
+

[pypy-commit] pypy py3.5: merge default into py3.5

2018-02-21 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93858:7019087f6069
Date: 2018-02-21 23:50 -0500
http://bitbucket.org/pypy/pypy/changeset/7019087f6069/

Log:merge default into py3.5

diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -430,9 +430,9 @@
 return SLOTS[key]
 except KeyError:
 slot_func = SLOT_FACTORIES[name](space, typedef, name, method_name)
-llfunc = llslot(space, slot_func) if slot_func else None
-SLOTS[key] = llfunc
-return llfunc
+api_func = slot_func.api_func if slot_func else None
+SLOTS[key] = api_func
+return api_func
 
 
 def make_unary_slot(space, typedef, name, attr):
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -265,10 +265,11 @@
 def update_all_slots_builtin(space, w_type, pto):
 typedef = w_type.layout.typedef
 for method_name, slot_name, slot_names, slot_apifunc in 
slotdefs_for_tp_slots:
-slot_llfunc = get_slot_tp_function(space, typedef, slot_name, 
method_name)
-if not slot_llfunc:
+slot_apifunc = get_slot_tp_function(space, typedef, slot_name, 
method_name)
+if not slot_apifunc:
 warn_missing_slot(space, method_name, slot_name, w_type)
 continue
+slot_llfunc = slot_apifunc.get_llhelper(space)
 fill_slot(space, pto, w_type, slot_names, slot_llfunc)
 
 @specialize.arg(3)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5, disable mapdict-size-limit

2018-02-13 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93819:38f2eb1313e4
Date: 2018-02-13 08:19 -0500
http://bitbucket.org/pypy/pypy/changeset/38f2eb1313e4/

Log:merge default into py3.5, disable mapdict-size-limit

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -27,7 +27,7 @@
 
 # the maximum number of attributes stored in mapdict (afterwards just use a
 # dict)
-LIMIT_MAP_ATTRIBUTES = 80
+LIMIT_MAP_ATTRIBUTES = 8000
 
 
 class AbstractAttribute(object):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-02-12 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93814:69009f281e55
Date: 2018-02-12 14:24 -0500
http://bitbucket.org/pypy/pypy/changeset/69009f281e55/

Log:merge default into py3.5

diff too long, truncating to 2000 out of 2875 lines

diff --git a/get_externals.py b/get_externals.py
new file mode 100644
--- /dev/null
+++ b/get_externals.py
@@ -0,0 +1,69 @@
+'''Get external dependencies for building PyPy
+they will end up in the platform.host().basepath, something like 
repo-root/external
+'''
+
+from __future__ import print_function
+
+import argparse
+import os
+import zipfile
+from subprocess import Popen, PIPE
+from rpython.translator.platform import host
+
+def runcmd(cmd, verbose):
+stdout = stderr = ''
+report = False
+try:
+p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+stdout, stderr = p.communicate()
+if p.wait() != 0 or verbose:
+report = True
+except Exception as e:
+stderr = str(e) + '\n' + stderr
+report = True
+if report:
+print('running "%s" returned\n%s\n%s' % (' '.join(cmd), stdout, 
stderr))
+if stderr:
+raise RuntimeError(stderr)
+
+def checkout_repo(dest='externals', org='pypy', branch='default', 
verbose=False):
+url = 'https://bitbucket.org/{}/externals'.format(org)
+if not os.path.exists(dest):
+cmd = ['hg','clone',url,dest]
+runcmd(cmd, verbose)
+cmd = ['hg','-R', dest, 'update',branch]
+runcmd(cmd, verbose)
+
+def extract_zip(externals_dir, zip_path):
+with zipfile.ZipFile(os.fspath(zip_path)) as zf:
+zf.extractall(os.fspath(externals_dir))
+return externals_dir / zf.namelist()[0].split('/')[0]
+
+def parse_args():
+p = argparse.ArgumentParser()
+p.add_argument('-v', '--verbose', action='store_true')
+p.add_argument('-O', '--organization',
+   help='Organization owning the deps repos', default='pypy')
+p.add_argument('-e', '--externals', default=host.externals,
+   help='directory in which to store dependencies',
+   )
+p.add_argument('-b', '--branch', default=host.externals_branch,
+   help='branch to check out',
+   )
+p.add_argument('-p', '--platform', default=None,
+   help='someday support cross-compilation, ignore for now',
+   )
+return p.parse_args()
+
+
+def main():
+args = parse_args()
+checkout_repo(
+dest=args.externals,
+org=args.organization,
+branch=args.branch,
+verbose=args.verbose,
+)
+
+if __name__ == '__main__':
+main()
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -40,3 +40,7 @@
 .. branch: memory-accounting
 
 Improve way to describe memory
+
+.. branch: msvc14
+
+Allow compilaiton with Visual Studio 2017 compiler suite on windows
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -39,10 +39,24 @@
 
 .. _Microsoft Visual C++ Compiler for Python 2.7: 
https://www.microsoft.com/en-us/download/details.aspx?id=44266
 
+Installing "Build Tools for Visual Studio 2017" (for Python 3)
+--
+
+As documented in the CPython Wiki_, CPython now recommends Visual C++ version
+14.0. A compact version of the compiler suite can be obtained from Microsoft_
+downloads, search the page for "Build Tools for Visual Studio 2017".
+
+You will also need to install the the `Windows SDK`_ in order to use the 
+`mt.exe` mainfest compiler.
+
+.. _Wiki: https://wiki.python.org/moin/WindowsCompilers
+.. _Microsoft: https://www.visualstudio.com/downloads
+.. _`Windows SDK`: 
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
+
 Translating PyPy with Visual Studio
 ---
 
-We routinely test translation using v9, also known as Visual Studio 2008.
+We routinely test translation of PyPy 2.7 using v9 and PyPy 3 with vc14.
 Other configurations may work as well.
 
 The translation scripts will set up the appropriate environment variables
@@ -82,8 +96,8 @@
 
 .. _build instructions: http://pypy.org/download.html#building-from-source
 
-Setting Up Visual Studio for building SSL in Python3
-
+Setting Up Visual Studio 9.0 for building SSL in Python3
+
 
 On Python3, the ``ssl`` module is based on ``cffi``, and requires a build step 
after
 translation. However ``distutils`` does not support the Micorosft-provided 
Visual C
@@ -132,243 +146,14 @@
 Installing external packages
 
 
-On Windows, there is no standard place where to download, build and
-install third-party libraries.  We recommend installing them in the parent
-directory of the pypy checkout.  For example, if you installed 

[pypy-commit] pypy py3.5: merge default into py3.5

2018-02-09 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93794:5c20792cdaa9
Date: 2018-02-09 16:28 -0500
http://bitbucket.org/pypy/pypy/changeset/5c20792cdaa9/

Log:merge default into py3.5

diff --git a/rpython/memory/gctypelayout.py b/rpython/memory/gctypelayout.py
--- a/rpython/memory/gctypelayout.py
+++ b/rpython/memory/gctypelayout.py
@@ -97,7 +97,7 @@
 
 def q_destructor_or_custom_trace(self, typeid):
 if not self.get(typeid).customdata:
-return lltype.nullptr(GCData.CUSTOM_DATA_STRUCT)
+return lltype.nullptr(GCData.CUSTOM_FUNC_PTR.TO)
 return self.get(typeid).customdata.customfunc
 
 def q_is_old_style_finalizer(self, typeid):
diff --git a/rpython/translator/c/test/test_newgc.py 
b/rpython/translator/c/test/test_newgc.py
--- a/rpython/translator/c/test/test_newgc.py
+++ b/rpython/translator/c/test/test_newgc.py
@@ -573,7 +573,7 @@
 return compute_hash(x)
 for size in ([random.randrange(0, 260) for i in range(10)] +
  [random.randrange(260, 6)]):
-print 'PREBUILT DICTIONARY OF SIZE', size
+#print 'PREBUILT DICTIONARY OF SIZE', size
 keys = [X() for j in range(size)]
 d = r_dict(keq, khash)
 for j in range(size):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2018-02-09 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93790:4e598c42abcc
Date: 2018-02-09 08:59 -0500
http://bitbucket.org/pypy/pypy/changeset/4e598c42abcc/

Log:merge default into py3.5

diff too long, truncating to 2000 out of 4107 lines

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -155,9 +155,10 @@
 factory = Connection if not factory else factory
 # an sqlite3 db seems to be around 100 KiB at least (doesn't matter if
 # backed by :memory: or a file)
+res = factory(database, timeout, detect_types, isolation_level,
+check_same_thread, factory, cached_statements, uri)
 add_memory_pressure(100 * 1024)
-return factory(database, timeout, detect_types, isolation_level,
-check_same_thread, factory, cached_statements, uri)
+return res
 
 
 def _unicode_text_factory(x):
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,11 +1,12 @@
 Metadata-Version: 1.1
 Name: cffi
-Version: 1.11.3
+Version: 1.11.4
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
 Author-email: python-c...@googlegroups.com
 License: MIT
+Description-Content-Type: UNKNOWN
 Description: 
 CFFI
 
@@ -27,5 +28,7 @@
 Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
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
 from .error import CDefError, FFIError, VerificationError, VerificationMissing
 
-__version__ = "1.11.3"
-__version_info__ = (1, 11, 3)
+__version__ = "1.11.4"
+__version_info__ = (1, 11, 4)
 
 # 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/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -8,37 +8,20 @@
the same works for the other two macros.  Py_DEBUG implies them,
but not the other way around.
 
-   Issue #350: more mess: on Windows, with _MSC_VER, we have to define
-   Py_LIMITED_API even before including pyconfig.h.  In that case, we
-   guess what pyconfig.h will do to the macros above, and check our
-   guess after the #include.
+   Issue #350 is still open: on Windows, the code here causes it to link
+   with PYTHON36.DLL (for example) instead of PYTHON3.DLL.  A fix was
+   attempted in 164e526a5515 and 14ce6985e1c3, but reverted: virtualenv
+   does not make PYTHON3.DLL available, and so the "correctly" compiled
+   version would not run inside a virtualenv.  We will re-apply the fix
+   after virtualenv has been fixed for some time.  For explanation, see
+   issue #355.  For a workaround if you want PYTHON3.DLL and don't worry
+   about virtualenv, see issue #350.  See also 'py_limited_api' in
+   setuptools_ext.py.
 */
 #if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
-#  ifdef _MSC_VER
-#if !defined(_DEBUG) && !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && 
!defined(Py_REF_DEBUG)
-#  define Py_LIMITED_API
-#endif
-#include 
- /* sanity-check: Py_LIMITED_API will cause crashes if any of these
-are also defined.  Normally, the Python file PC/pyconfig.h does not
-cause any of these to be defined, with the exception that _DEBUG
-causes Py_DEBUG.  Double-check that. */
-#ifdef Py_LIMITED_API
-#  if defined(Py_DEBUG)
-#error "pyconfig.h unexpectedly defines Py_DEBUG but _DEBUG is not set"
-#  endif
-#  if defined(Py_TRACE_REFS)
-#error "pyconfig.h unexpectedly defines Py_TRACE_REFS"
-#  endif
-#  if defined(Py_REF_DEBUG)
-#error "pyconfig.h unexpectedly defines Py_REF_DEBUG"
-#  endif
-#endif
-#  else
-#include 
-#if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
-#  define Py_LIMITED_API
-#endif
+#  include 
+#  if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
+#define Py_LIMITED_API
 #  endif
 #endif
 
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -247,7 +247,7 @@
 
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.11.3"
+  

[pypy-commit] pypy py3.5: merge default into py3.5

2018-01-19 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93685:6742308b0f34
Date: 2018-01-19 14:45 +0200
http://bitbucket.org/pypy/pypy/changeset/6742308b0f34/

Log:merge default into py3.5

diff too long, truncating to 2000 out of 2456 lines

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -10,3 +10,7 @@
 Big refactoring of some cpyext code, which avoids a lot of nonsense when
 calling C from Python and vice-versa: the result is a big speedup in
 function/method calls, up to 6 times faster.
+
+.. branch: cpyext-datetime2
+
+Support ``tzinfo`` field on C-API datetime objects, fixes latest pandas HEAD
diff --git a/pypy/interpreter/astcompiler/assemble.py 
b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -1,7 +1,7 @@
 """Python control flow graph generation and bytecode assembly."""
 
+import math
 import os
-from rpython.rlib import rfloat
 from rpython.rlib.objectmodel import specialize, we_are_translated
 
 from pypy.interpreter.astcompiler import ast, consts, misc, symtable
@@ -269,7 +269,7 @@
 w_type = space.type(obj)
 if space.is_w(w_type, space.w_float):
 val = space.float_w(obj)
-if val == 0.0 and rfloat.copysign(1., val) < 0:
+if val == 0.0 and math.copysign(1., val) < 0:
 w_key = space.newtuple([obj, space.w_float, space.w_None])
 else:
 w_key = space.newtuple([obj, space.w_float])
@@ -279,9 +279,9 @@
 real = space.float_w(w_real)
 imag = space.float_w(w_imag)
 real_negzero = (real == 0.0 and
-rfloat.copysign(1., real) < 0)
+math.copysign(1., real) < 0)
 imag_negzero = (imag == 0.0 and
-rfloat.copysign(1., imag) < 0)
+math.copysign(1., imag) < 0)
 if real_negzero and imag_negzero:
 tup = [obj, space.w_complex, space.w_None, space.w_None,
space.w_None]
diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -2,6 +2,8 @@
 Interp-level implementation of the basic space operations.
 """
 
+import math
+
 from pypy.interpreter import gateway
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import unwrap_spec, WrappedDefault
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -58,6 +58,14 @@
 }
 
 
+class PyPyDateTime(MixedModule):
+appleveldefs = {}
+interpleveldefs = {
+'dateinterop': 'interp_pypydatetime.W_DateTime_Date',
+'timeinterop': 'interp_pypydatetime.W_DateTime_Time',
+'deltainterop'   : 'interp_pypydatetime.W_DateTime_Delta',
+}
+
 class Module(MixedModule):
 """ PyPy specific "magic" functions. A lot of them are experimental and
 subject to change, many are internal. """
@@ -107,6 +115,7 @@
 "thread": ThreadModule,
 "intop": IntOpModule,
 "os": OsModule,
+'_pypydatetime': PyPyDateTime,
 }
 
 def setup_after_space_initialization(self):
diff --git a/pypy/module/__pypy__/interp_pypydatetime.py 
b/pypy/module/__pypy__/interp_pypydatetime.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/__pypy__/interp_pypydatetime.py
@@ -0,0 +1,24 @@
+from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.typedef import TypeDef
+from pypy.interpreter.gateway import interp2app
+from rpython.tool.sourcetools import func_with_new_name
+
+def create_class(name):
+class W_Class(W_Root):
+'builtin base clasee for datetime.%s to allow interop with cpyext' % 
name
+def descr_new__(space, w_type):
+return space.allocate_instance(W_Class, w_type)
+
+W_Class.typedef = TypeDef(name,
+__new__ = interp2app(func_with_new_name(
+W_Class.descr_new__.im_func,
+'%s_new' % (name,))),
+)
+W_Class.typedef.acceptable_as_base_class = True
+return W_Class
+
+W_DateTime_Time = create_class('pypydatetime_time')
+W_DateTime_Date = create_class('pypydatetime_date')
+W_DateTime_Delta = create_class('pypydatetime_delta')
+
+
diff --git a/pypy/module/cmath/test/test_cmath.py 
b/pypy/module/cmath/test/test_cmath.py
--- a/pypy/module/cmath/test/test_cmath.py
+++ b/pypy/module/cmath/test/test_cmath.py
@@ -1,5 +1,4 @@
 from __future__ import with_statement
-from rpython.rlib.rfloat import copysign, isnan, isinf
 from pypy.module.cmath import interp_cmath
 import os, sys, math
 
@@ -11,7 +10,7 @@
 assert isinstance(sqrt_special_values[5][1], tuple)
 assert

[pypy-commit] pypy py3.5: merge default

2017-12-21 Thread fijal
Author: fijal
Branch: py3.5
Changeset: r93534:4f88f2f2d3f2
Date: 2017-12-21 15:51 +0200
http://bitbucket.org/pypy/pypy/changeset/4f88f2f2d3f2/

Log:merge default

diff --git a/extra_tests/requirements.txt b/extra_tests/requirements.txt
--- a/extra_tests/requirements.txt
+++ b/extra_tests/requirements.txt
@@ -1,2 +1,3 @@
 pytest
 hypothesis
+vmprof
diff --git a/extra_tests/test_vmprof_greenlet.py 
b/extra_tests/test_vmprof_greenlet.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_vmprof_greenlet.py
@@ -0,0 +1,28 @@
+import time
+import pytest
+import greenlet
+vmprof = pytest.importorskip('vmprof')
+
+def count_samples(filename):
+stats = vmprof.read_profile(filename)
+return len(stats.profiles)
+
+def cpuburn(duration):
+end = time.time() + duration
+while time.time() < end:
+pass
+
+def test_sampling_inside_callback(tmpdir):
+# see also test_sampling_inside_callback inside
+# pypy/module/_continuation/test/test_stacklet.py
+#
+G = greenlet.greenlet(cpuburn)
+fname = tmpdir.join('log.vmprof')
+with fname.open('w+b') as f:
+vmprof.enable(f.fileno(), 1/250.0)
+G.switch(0.1)
+vmprof.disable()
+
+samples = count_samples(str(fname))
+# 0.1 seconds at 250Hz should be 25 samples
+assert 23 < samples < 27
diff --git a/lib-python/2.7/subprocess.py b/lib-python/2.7/subprocess.py
--- a/lib-python/2.7/subprocess.py
+++ b/lib-python/2.7/subprocess.py
@@ -1296,7 +1296,7 @@
   'copyfile' in caller.f_globals):
 dest_dir = sys.pypy_resolvedirof(target_executable)
 src_dir = sys.pypy_resolvedirof(sys.executable)
-for libname in ['libpypy-c.so', 'libpypy-c.dylib']:
+for libname in ['libpypy-c.so', 'libpypy-c.dylib', 'libpypy-c.dll']:
 dest_library = os.path.join(dest_dir, libname)
 src_library = os.path.join(src_dir, libname)
 if os.path.exists(src_library):
diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-v5.10.0.rst
release-v5.9.0.rst
release-v5.8.0.rst
release-v5.7.1.rst
diff --git a/pypy/doc/release-v5.10.0.rst b/pypy/doc/release-v5.10.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-v5.10.0.rst
@@ -0,0 +1,94 @@
+==
+PyPy2.7 and PyPy3.5 v5.10 dual release
+==
+
+The PyPy team is proud to release both PyPy2.7 v5.10 (an interpreter supporting
+Python 2.7 syntax), and a final PyPy3.5 v5.10 (an interpreter for Python
+3.5 syntax). The two releases are both based on much the same codebase, thus
+the dual release.
+
+This release is an incremental release with very few new features, the main
+feature being the final PyPy3.5 release that works on linux and OS X with beta
+windows support. It also includes fixes for `vmprof`_ cooperation with 
greenlets.
+
+Compared to 5.9, the 5.10 release contains mostly bugfixes and small 
improvements.
+We have in the pipeline big new features coming for PyPy 6.0 that did not make
+the release cut and should be available within the next couple months.
+
+As always, this release is 100% compatible with the previous one and fixed
+several issues and bugs raised by the growing community of PyPy users.
+As always, we strongly recommend updating.
+
+This release concludes the Mozilla Open Source `grant`_ for having a compatible
+PyPy 3.5 release and we're very grateful for that.  Of course, we will continue
+to improve PyPy 3.5 and probably move to 3.6 during the course of 2018.
+
+You can download the v5.10 releases here:
+
+http://pypy.org/download.html
+
+We would like to thank our donors for the continued support of the PyPy
+project.
+
+We would also like to thank our contributors and
+encourage new people to join the project. PyPy has many
+layers and we need help with all of them: `PyPy`_ and `RPython`_ documentation
+improvements, tweaking popular `modules`_ to run on pypy, or general `help`_
+with making RPython's JIT even better.
+
+.. _vmprof: http://vmprof.readthedocs.io
+.. _grant: 
https://morepypy.blogspot.com/2016/08/pypy-gets-funding-from-mozilla-for.html
+.. _`PyPy`: index.html
+.. _`RPython`: https://rpython.readthedocs.org
+.. _`modules`: project-ideas.html#make-more-python-modules-pypy-friendly
+.. _`help`: project-ideas.html
+
+What is PyPy?
+=
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7 and CPython 3.5. It's fast (`PyPy and CPython 2.7.x`_ performance 
comparison)
+due to its integrated tracing JIT compiler.
+
+We also welcome developers of other `dynamic languages`_ to see what RPython
+can do for them.
+
+The PyPy 2.7 release supports: 
+
+  * **x86** machines on most common operating systems
+(Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, 

[pypy-commit] pypy py3.5: merge default into py3.5

2017-11-23 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93154:d2807ddb8178
Date: 2017-11-24 09:17 +0200
http://bitbucket.org/pypy/pypy/changeset/d2807ddb8178/

Log:merge default into py3.5

diff --git a/pypy/module/_continuation/test/conftest.py 
b/pypy/module/_continuation/test/conftest.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_continuation/test/conftest.py
@@ -0,0 +1,7 @@
+import pytest
+import sys
+
+def pytest_configure(config):
+if sys.platform.startswith('linux'):
+from rpython.rlib.rvmprof.cintf import configure_libbacktrace_linux
+configure_libbacktrace_linux()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2017-11-23 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r93152:ce6402cbdf3c
Date: 2017-11-23 22:08 +0200
http://bitbucket.org/pypy/pypy/changeset/ce6402cbdf3c/

Log:merge default into py3.5

diff --git a/pypy/module/_io/interp_stringio.py 
b/pypy/module/_io/interp_stringio.py
--- a/pypy/module/_io/interp_stringio.py
+++ b/pypy/module/_io/interp_stringio.py
@@ -184,9 +184,7 @@
 start,
 end
 )
-if endpos >= 0:
-endpos += start
-else:
+if endpos < 0:
 endpos = end
 assert endpos >= 0
 self.pos = endpos
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -216,44 +216,41 @@
 
 def _find_line_ending(self, line, start, end):
 size = end - start
-if self.readtranslate:
-
-# Newlines are already translated, only search for \n
-pos = line.find(u'\n', start, end)
-if pos >= 0:
-return pos - start + 1, 0
-else:
-return -1, size
-elif self.readuniversal:
+if self.readuniversal:
 # Universal newline search. Find any of \r, \r\n, \n
 # The decoder ensures that \r\n are not split in two pieces
-i = 0
+i = start
 while True:
-# Fast path for non-control chars. The loop always ends
-# since the Py_UNICODE storage is NUL-terminated.
-while i < size and line[start + i] > '\r':
+# Fast path for non-control chars.
+while i < end and line[i] > '\r':
 i += 1
-if i >= size:
+if i >= end:
 return -1, size
-ch = line[start + i]
+ch = line[i]
 i += 1
 if ch == '\n':
 return i, 0
 if ch == '\r':
-if line[start + i] == '\n':
+if line[i] == '\n':
 return i + 1, 0
 else:
 return i, 0
+if self.readtranslate:
+# Newlines are already translated, only search for \n
+newline = u'\n'
 else:
 # Non-universal mode.
-pos = line.find(self.readnl, start, end)
-if pos >= 0:
-return pos - start + len(self.readnl), 0
-else:
-pos = line.find(self.readnl[0], start, end)
-if pos >= 0:
-return -1, pos - start
-return -1, size
+newline = self.readnl
+end_scan = end - len(newline) + 1
+for i in range(start, end_scan):
+ch = line[i]
+if ch == newline[0]:
+for j in range(1, len(newline)):
+if line[i + j] != newline[j]:
+break
+else:
+return i + len(newline), 0
+return -1, end_scan
 
 
 W_TextIOBase.typedef = TypeDef(
@@ -549,8 +546,13 @@
 # _
 # read methods
 
-def _set_decoded_chars(self, chars):
-self.decoded_chars = chars
+def _unset_decoded(self):
+self.decoded_chars = None
+self.decoded_chars_used = 0
+
+def _set_decoded(self, space, w_decoded):
+check_decoded(space, w_decoded)
+self.decoded_chars = space.unicode_w(w_decoded)
 self.decoded_chars_used = 0
 
 def _get_decoded_chars(self, size):
@@ -574,6 +576,10 @@
 self.decoded_chars_used += size
 return chars
 
+def _has_data(self):
+return (self.decoded_chars is not None and
+self.decoded_chars_used < len(self.decoded_chars))
+
 def _read_chunk(self, space):
 """Read and decode the next chunk of data from the BufferedReader.
 The return value is True unless EOF was reached.  The decoded string
@@ -616,8 +622,7 @@
 eof = input_buf.getlength() == 0
 w_decoded = space.call_method(self.w_decoder, "decode",
   w_input, space.newbool(eof))
-check_decoded(space, w_decoded)
-self._set_decoded_chars(space.unicode_w(w_decoded))
+self._set_decoded(space, w_decoded)
 if space.len_w(w_decoded) > 0:
 eof = False
 
@@ -629,6 +634,19 @@
 
 return not eof
 
+def _ensure_data(self, space):
+while not self._has_data():
+try:
+if not self._read_chunk(space):
+self._unset_decoded()
+self.snapshot = None
+return False
+except OperationError as e:
+if trap_eintr(space, e):
+continue
+raise
+return True
+
 def next_w(sel

[pypy-commit] pypy py3.5: merge default into py3.5

2017-11-02 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r92902:6311c6a24eba
Date: 2017-11-02 10:10 +0200
http://bitbucket.org/pypy/pypy/changeset/6311c6a24eba/

Log:merge default into py3.5

diff --git a/pypy/tool/build_cffi_imports.py b/pypy/tool/build_cffi_imports.py
--- a/pypy/tool/build_cffi_imports.py
+++ b/pypy/tool/build_cffi_imports.py
@@ -145,6 +145,12 @@
 
 shutil.rmtree(str(join(basedir,'lib_pypy','__pycache__')),
   ignore_errors=True)
+# be sure pip, setuptools are installed in a fresh pypy
+# allows proper functioning of cffi on win32 with newer vc compilers
+# XXX move this to a build slave step?
+status, stdout, stderr = run_subprocess(str(pypy_c), ['-c', 'import 
setuptools'])
+if status  != 0:
+status, stdout, stderr = run_subprocess(str(pypy_c), ['-m', 
'ensurepip'])
 failures = []
 
 for key, module in sorted(cffi_build_scripts.items()):
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -20,6 +20,7 @@
 import py
 import fnmatch
 import subprocess
+from pypy.tool.release.smartstrip import smartstrip
 
 USE_ZIPFILE_MODULE = sys.platform == 'win32'
 
@@ -223,15 +224,8 @@
 old_dir = os.getcwd()
 try:
 os.chdir(str(builddir))
-if not options.nostrip:
-for source, target in binaries:
-if sys.platform == 'win32':
-pass
-elif sys.platform == 'darwin':
-# 'strip' fun: see issue #587 for why -x
-os.system("strip -x " + str(bindir.join(target)))# 
ignore errors
-else:
-os.system("strip " + str(bindir.join(target)))# ignore 
errors
+for source, target in binaries:
+smartstrip(bindir.join(target), keep_debug=options.keep_debug)
 #
 if USE_ZIPFILE_MODULE:
 import zipfile
@@ -297,8 +291,8 @@
 help='do not build and package the %r cffi module' % 
(key,))
 parser.add_argument('--without-cffi', dest='no_cffi', action='store_true',
 help='skip building *all* the cffi modules listed above')
-parser.add_argument('--nostrip', dest='nostrip', action='store_true',
-help='do not strip the exe, making it ~10MB larger')
+parser.add_argument('--no-keep-debug', dest='keep_debug',
+action='store_false', help='do not keep debug symbols')
 parser.add_argument('--rename_pypy_c', dest='pypy_c', type=str, 
default=pypy_exe,
 help='target executable name, defaults to "%s"' % pypy_exe)
 parser.add_argument('--archive-name', dest='name', type=str, default='',
@@ -317,8 +311,8 @@
 '(default on OS X)')
 options = parser.parse_args(args)
 
-if os.environ.has_key("PYPY_PACKAGE_NOSTRIP"):
-options.nostrip = True
+if os.environ.has_key("PYPY_PACKAGE_NOKEEPDEBUG"):
+options.keep_debug = False
 if os.environ.has_key("PYPY_PACKAGE_WITHOUTTK"):
 options.no_tk = True
 if os.environ.has_key("PYPY_EMBED_DEPENDENCIES"):
diff --git a/pypy/tool/release/smartstrip.py b/pypy/tool/release/smartstrip.py
new file mode 100644
--- /dev/null
+++ b/pypy/tool/release/smartstrip.py
@@ -0,0 +1,32 @@
+"""
+Strip symbols from an executable, but keep them in a .debug file
+"""
+
+import sys
+import os
+import py
+
+def _strip(exe):
+if sys.platform == 'win32':
+pass
+elif sys.platform == 'darwin':
+# 'strip' fun: see issue #587 for why -x
+os.system("strip -x " + str(exe))# ignore errors
+else:
+os.system("strip " + str(exe))   # ignore errors
+
+def _extract_debug_symbols(exe, debug):
+if sys.platform == 'linux2':
+os.system("objcopy --only-keep-debug %s %s" % (exe, debug))
+os.system("objcopy --add-gnu-debuglink=%s %s" % (debug, exe))
+
+def smartstrip(exe, keep_debug=True):
+exe = py.path.local(exe)
+debug = py.path.local(str(exe) + '.debug')
+if keep_debug:
+_extract_debug_symbols(exe, debug)
+_strip(exe)
+
+
+if __name__ == '__main__':
+smartstrip(sys.argv[1])
diff --git a/pypy/tool/release/test/test_smartstrip.py 
b/pypy/tool/release/test/test_smartstrip.py
new file mode 100644
--- /dev/null
+++ b/pypy/tool/release/test/test_smartstrip.py
@@ -0,0 +1,50 @@
+import pytest
+import sys
+import os
+from commands import getoutput
+from pypy.tool.release.smartstrip import smartstrip
+
+@pytest.fixture
+def exe(tmpdir):
+src = tmpdir.join("myprog.c")
+src.write("""
+int foo(int a, int b) {
+return a+b;
+}
+int main(void) { }
+""")
+exe = tmpdir.join("myprog")
+ret = os.system("gcc -o %s %s" % (exe, src))
+assert ret == 0
+return exe
+
+def info_symbol(exe, symbol):
+out = getoutput("gdb %s -ex 'info symbol %s' -ex 'quit'" % (exe, symbol))
+lines = out.splitlines()
+return lines[-1]
+
+@p

[pypy-commit] pypy py3.5: merge default into branch

2017-10-30 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r92885:623c5cbb6132
Date: 2017-10-30 18:58 +0200
http://bitbucket.org/pypy/pypy/changeset/623c5cbb6132/

Log:merge default into branch

diff too long, truncating to 2000 out of 3230 lines

diff --git a/_pytest/terminal.py b/_pytest/terminal.py
--- a/_pytest/terminal.py
+++ b/_pytest/terminal.py
@@ -366,11 +366,11 @@
 EXIT_OK, EXIT_TESTSFAILED, EXIT_INTERRUPTED, EXIT_USAGEERROR,
 EXIT_NOTESTSCOLLECTED)
 if exitstatus in summary_exit_codes:
-self.config.hook.pytest_terminal_summary(terminalreporter=self)
 self.summary_errors()
 self.summary_failures()
 self.summary_warnings()
 self.summary_passes()
+self.config.hook.pytest_terminal_summary(terminalreporter=self)
 if exitstatus == EXIT_INTERRUPTED:
 self._report_keyboardinterrupt()
 del self._keyboardinterrupt_memo
diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -182,6 +182,57 @@
 technical difficulties.
 
 
+What about numpy, numpypy, micronumpy?
+--
+
+Way back in 2011, the PyPy team `started to reimplement`_ numpy in PyPy.  It
+has two pieces:
+
+  * the builtin module :source:`pypy/module/micronumpy`: this is written in
+RPython and roughly covers the content of the ``numpy.core.multiarray``
+module. Confusingly enough, this is available in PyPy under the name
+``_numpypy``.  It is included by default in all the official releases of
+PyPy (but it might be dropped in the future).
+
+  * a fork_ of the official numpy repository maintained by us and informally
+called ``numpypy``: even more confusing, the name of the repo on bitbucket
+is ``numpy``.  The main difference with the upstream numpy, is that it is
+based on the micronumpy module written in RPython, instead of of
+``numpy.core.multiarray`` which is written in C.
+
+Moreover, it is also possible to install the upstream version of ``numpy``:
+its core is written in C and it runs on PyPy under the cpyext compatibility
+layer. This is what you get if you do ``pypy -m pip install numpy``.
+
+
+Should I install numpy or numpypy?
+---
+
+TL;DR version: you should use numpy. You can install it by doing ``pypy -m pip
+install numpy``.  You might also be interested in using the experimental `PyPy
+binary wheels`_ to save compilation time.
+
+The upstream ``numpy`` is written in C, and runs under the cpyext
+compatibility layer.  Nowadays, cpyext is mature enough that you can simply
+use the upstream ``numpy``, since it passes 99.9% of the test suite. At the
+moment of writing (October 2017) the main drawback of ``numpy`` is that cpyext
+is infamously slow, and thus it has worse performance compared to
+``numpypy``. However, we are actively working on improving it, as we expect to
+reach the same speed, eventually.
+
+On the other hand, ``numpypy`` is more JIT-friendly and very fast to call,
+since it is written in RPython: but it is a reimplementation, and it's hard to
+be completely compatible: over the years the project slowly matured and
+eventually it was able to call out to the LAPACK and BLAS libraries to speed
+matrix calculations, and reached around an 80% parity with the upstream
+numpy. However, 80% is far from 100%.  Since cpyext/numpy compatibility is
+progressing fast, we have discontinued support for ``numpypy``.
+
+.. _`started to reimplement`: 
https://morepypy.blogspot.co.il/2011/05/numpy-in-pypy-status-and-roadmap.html
+.. _fork: https://bitbucket.org/pypy/numpy
+.. _`PyPy binary wheels`: https://github.com/antocuni/pypy-wheels
+
+
 Is PyPy more clever than CPython about Tail Calls?
 --
 
diff --git a/pypy/module/_cppyy/__init__.py b/pypy/module/_cppyy/__init__.py
--- a/pypy/module/_cppyy/__init__.py
+++ b/pypy/module/_cppyy/__init__.py
@@ -7,7 +7,7 @@
 interpleveldefs = {
 '_resolve_name'  : 'interp_cppyy.resolve_name',
 '_scope_byname'  : 'interp_cppyy.scope_byname',
-'_template_byname'   : 'interp_cppyy.template_byname',
+'_is_template'   : 'interp_cppyy.is_template',
 '_std_string_name'   : 'interp_cppyy.std_string_name',
 '_set_class_generator'   : 'interp_cppyy.set_class_generator',
 '_set_function_generator': 'interp_cppyy.set_function_generator',
@@ -15,7 +15,9 @@
 '_get_nullptr'   : 'interp_cppyy.get_nullptr',
 'CPPClassBase'   : 'interp_cppyy.W_CPPClass',
 'addressof'  : 'interp_cppyy.addressof',
+'_bind_object'   : 'interp_cppyy._bind_object',
 'bind_object': 'interp_cppyy.bind_object',
+'move'   : 'interp_cppyy.move',
 }
 
 appleveldefs = {
diff --git a/pypy/module/_cppyy/capi/loadable_capi.py 

[pypy-commit] pypy py3.5: merge default into py3.5

2017-10-27 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r92861:b45ee2feb1b1
Date: 2017-10-27 17:32 +0300
http://bitbucket.org/pypy/pypy/changeset/b45ee2feb1b1/

Log:merge default into py3.5

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -1080,21 +1080,25 @@
 if '\0' in sql:
 raise ValueError("the query contains a null character")
 
-first_word = sql.lstrip().split()[0].upper()
-if first_word == "":
+
+if sql:
+first_word = sql.lstrip().split()[0].upper()
+if first_word == '':
+self._type = _STMT_TYPE_INVALID
+if first_word == "SELECT":
+self._type = _STMT_TYPE_SELECT
+elif first_word == "INSERT":
+self._type = _STMT_TYPE_INSERT
+elif first_word == "UPDATE":
+self._type = _STMT_TYPE_UPDATE
+elif first_word == "DELETE":
+self._type = _STMT_TYPE_DELETE
+elif first_word == "REPLACE":
+self._type = _STMT_TYPE_REPLACE
+else:
+self._type = _STMT_TYPE_OTHER
+else:
 self._type = _STMT_TYPE_INVALID
-elif first_word == "SELECT":
-self._type = _STMT_TYPE_SELECT
-elif first_word == "INSERT":
-self._type = _STMT_TYPE_INSERT
-elif first_word == "UPDATE":
-self._type = _STMT_TYPE_UPDATE
-elif first_word == "DELETE":
-self._type = _STMT_TYPE_DELETE
-elif first_word == "REPLACE":
-self._type = _STMT_TYPE_REPLACE
-else:
-self._type = _STMT_TYPE_OTHER
 
 if isinstance(sql, unicode):
 sql = sql.encode('utf-8')
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -582,6 +582,7 @@
 'PyComplex_AsCComplex', 'PyComplex_FromCComplex',
 
 'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer', 
'PyObject_CheckReadBuffer',
+'PyBuffer_GetPointer', 'PyBuffer_ToContiguous', 'PyBuffer_FromContiguous',
 
 'PyImport_ImportModuleLevel',
 
diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -308,6 +308,31 @@
 PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *, const void **, Py_ssize_t *);
 PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *, void **, Py_ssize_t *);
 PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *);
+PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
+/* Get the memory area pointed to by the indices for the buffer given.
+   Note that view->ndim is the assumed size of indices
+*/
+
+PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view,
+   Py_ssize_t len, char fort);
+PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf,
+ Py_ssize_t len, char fort);
+/* Copy len bytes of data from the contiguous chunk of memory
+   pointed to by buf into the buffer exported by obj.  Return
+   0 on success and return -1 and raise a PyBuffer_Error on
+   error (i.e. the object does not have a buffer interface or
+   it is not working).
+
+   If fort is 'F' and the object is multi-dimensional,
+   then the data will be copied into the array in
+   Fortran-style (first dimension varies the fastest).  If
+   fort is 'C', then the data will be copied into the array
+   in C-style (last dimension varies the fastest).  If fort
+   is 'A', then it does not matter and the copy will be made
+   in whatever way is more efficient.
+
+*/
+
 
 #define PyObject_MALLOC PyObject_Malloc
 #define PyObject_REALLOCPyObject_Realloc
diff --git a/pypy/module/cpyext/src/abstract.c 
b/pypy/module/cpyext/src/abstract.c
--- a/pypy/module/cpyext/src/abstract.c
+++ b/pypy/module/cpyext/src/abstract.c
@@ -96,6 +96,163 @@
 return 0;
 }
 
+void*
+PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices)
+{
+char* pointer;
+int i;
+pointer = (char *)view->buf;
+for (i = 0; i < view->ndim; i++) {
+pointer += view->strides[i]*indices[i];
+if ((view->suboffsets != NULL) && (view->suboffsets[i] >= 0)) {
+pointer = *((char**)pointer) + view->suboffsets[i];
+}
+}
+return (void*)pointer;
+}
+
+void
+_Py_add_one_to_index_F(int nd, Py_ssize_t *index, const Py_ssize_t *shape)
+{
+int k;
+
+for (k=0; k=0; k--) {
+if (index[k] < shape[k]-1) {
+index[k]++;
+break;
+}
+else {
+index[k] = 0;
+}
+}
+}
+
+  /* view is not checked for consistency in either of these.  It is
+ assumed that the size of the buffer is view->len in
+ view->len / view->itemsize elements.
+  */
+
+int
+PyBuffer_ToContiguous(void *buf, Py_buffer *view

[pypy-commit] pypy py3.5: merge default into py3.5

2017-10-25 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r92845:7d0732ed45b9
Date: 2017-10-25 15:53 +0300
http://bitbucket.org/pypy/pypy/changeset/7d0732ed45b9/

Log:merge default into py3.5

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -1080,7 +1080,7 @@
 if '\0' in sql:
 raise ValueError("the query contains a null character")
 
-first_word = sql.lstrip().split(" ")[0].upper()
+first_word = sql.lstrip().split()[0].upper()
 if first_word == "":
 self._type = _STMT_TYPE_INVALID
 elif first_word == "SELECT":
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py 
b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -228,6 +228,14 @@
 cur.execute("create table test(a)")
 cur.executemany("insert into test values (?)", [[1], [2], [3]])
 assert cur.lastrowid is None
+# issue 2682
+cur.execute('''insert
+into test 
+values (?)
+''', (1, ))
+assert cur.lastrowid is not None
+cur.execute('''insert\t into test values (?) ''', (1, ))
+assert cur.lastrowid is not None
 
 def test_authorizer_bad_value(self, con):
 def authorizer_cb(action, arg1, arg2, dbname, source):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default into py3.5

2017-10-07 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r92633:e3a0b4e339d0
Date: 2017-10-08 00:21 +1100
http://bitbucket.org/pypy/pypy/changeset/e3a0b4e339d0/

Log:merge default into py3.5

diff --git a/pypy/module/_cppyy/test/conftest.py 
b/pypy/module/_cppyy/test/conftest.py
--- a/pypy/module/_cppyy/test/conftest.py
+++ b/pypy/module/_cppyy/test/conftest.py
@@ -4,7 +4,7 @@
 def pytest_runtest_setup(item):
 if py.path.local.sysfind('genreflex') is None:
 import pypy.module._cppyy.capi.loadable_capi as lcapi
-if 'dummy' in lcapi.reflection_library:
+if 'dummy' in lcapi.backend_library:
 # run only tests that are covered by the dummy backend and tests
 # that do not rely on reflex
 import os
@@ -33,7 +33,7 @@
 import pypy.module._cppyy.capi.loadable_capi as lcapi
 try:
 import ctypes
-ctypes.CDLL(lcapi.reflection_library)
+ctypes.CDLL(lcapi.backend_library)
 except Exception as e:
 if config.option.runappdirect:
 return   # "can't run dummy tests in -A"
@@ -71,4 +71,4 @@
 return
 raise
 
-lcapi.reflection_library = str(soname)
+lcapi.backend_library = str(soname)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default

2017-08-04 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: py3.5
Changeset: r92073:5d4625159d48
Date: 2017-08-04 14:50 +0200
http://bitbucket.org/pypy/pypy/changeset/5d4625159d48/

Log:merge default

diff too long, truncating to 2000 out of 2201 lines

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@
 RUNINTERP = $(PYPY_EXECUTABLE)
 endif
 
-.PHONY: cffi_imports
+.PHONY: pypy-c cffi_imports
 
 pypy-c:
@echo
@@ -32,7 +32,7 @@
@echo 
""
@echo
@sleep 5
-   $(RUNINTERP) rpython/bin/rpython -Ojit pypy/goal/targetpypystandalone.py
+   cd pypy/goal && $(RUNINTERP) ../../rpython/bin/rpython -Ojit 
targetpypystandalone.py
 
 # Note: the -jN option, or MAKEFLAGS=-jN, are not usable.  They are
 # replaced with an opaque --jobserver option by the time this Makefile
@@ -40,4 +40,4 @@
 # http://lists.gnu.org/archive/html/help-make/2010-08/msg00106.html
 
 cffi_imports: pypy-c
-   PYTHONPATH=. ./pypy-c pypy/tool/build_cffi_imports.py || /bin/true
+   PYTHONPATH=. pypy/goal/pypy-c pypy/tool/build_cffi_imports.py || 
/bin/true
diff --git a/lib-python/2.7/distutils/unixccompiler.py 
b/lib-python/2.7/distutils/unixccompiler.py
--- a/lib-python/2.7/distutils/unixccompiler.py
+++ b/lib-python/2.7/distutils/unixccompiler.py
@@ -226,7 +226,19 @@
 return "-L" + dir
 
 def _is_gcc(self, compiler_name):
-return "gcc" in compiler_name or "g++" in compiler_name
+# XXX PyPy workaround, look at the big comment below for more
+# context. On CPython, the hack below works fine because
+# `compiler_name` contains the name of the actual compiler which was
+# used at compile time (e.g. 'x86_64-linux-gnu-gcc' on my machine).
+# PyPy hardcodes it to 'cc', so the hack doesn't work, and the end
+# result is that we pass the wrong option to the compiler.
+#
+# The workaround is to *always* pretend to be GCC if we are on Linux:
+# this should cover the vast majority of real systems, including the
+# ones which use clang (which understands the '-Wl,-rpath' syntax as
+# well)
+return (sys.platform == "linux2" or
+"gcc" in compiler_name or "g++" in compiler_name)
 
 def runtime_library_dir_option(self, dir):
 # XXX Hackish, at the very least.  See Python bug #445902:
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -394,12 +394,17 @@
 replace_with = ' ' + replace_with
 return self._backend.getcname(cdecl, replace_with)
 
-def gc(self, cdata, destructor):
+def gc(self, cdata, destructor, size=0):
 """Return a new cdata object that points to the same
 data.  Later, when this new cdata object is garbage-collected,
 'destructor(old_cdata_object)' will be called.
+
+The optional 'size' gives an estimate of the size, used to
+trigger the garbage collection more eagerly.  So far only used
+on PyPy.  It tells the GC that the returned object keeps alive
+roughly 'size' bytes of external memory.
 """
-return self._backend.gcp(cdata, destructor)
+return self._backend.gcp(cdata, destructor, size)
 
 def _get_cached_btype(self, type):
 assert self._lock.acquire(False) is False
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -1002,7 +1002,7 @@
 
 _weakref_cache_ref = None
 
-def gcp(self, cdata, destructor):
+def gcp(self, cdata, destructor, size=0):
 if self._weakref_cache_ref is None:
 import weakref
 class MyRef(weakref.ref):
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -227,11 +227,6 @@
"use specialised tuples",
default=False),
 
-BoolOption("withcelldict",
-   "use dictionaries that are optimized for being used as 
module dicts",
-   default=False,
-   requires=[("objspace.honor__builtins__", False)]),
-
 BoolOption("withliststrategies",
"enable optimized ways to store lists of primitives ",
default=True),
@@ -291,7 +286,7 @@
 
 # extra optimizations with the JIT
 if level == 'jit':
-config.objspace.std.suggest(withcelldict=True)
+pass # none at the moment
 
 
 def enable_allworkingmodules(config):
diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -10,6 +10,18 @@
 minutes on a fast machine -- and RAM-hungry.  You will need **at least** 2 GB
 of memory on a 32-bit machine and 4GB on a 64-bit machine.
 
+Before you start
+
+
+Our normal 

[pypy-commit] pypy py3.5: merge default into py3.5

2017-03-18 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r90748:b6b60142458f
Date: 2017-03-18 21:47 +0200
http://bitbucket.org/pypy/pypy/changeset/b6b60142458f/

Log:merge default into py3.5

diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -27,14 +27,19 @@
 Building
 
 
-build with:
+First switch to or download the correct branch.  The basic choices are
+``default`` for Python 2.7 and, for Python 3.X, the corresponding py3.X
+branch (e.g. ``py3.5``).
+
+Build with:
 
 .. code-block:: console
 
 $ rpython/bin/rpython -Ojit pypy/goal/targetpypystandalone.py
 
-This ends up with ``pypy-c`` binary in the main pypy directory. We suggest
-to use virtualenv with the resulting pypy-c as the interpreter; you can
-find more details about various installation schemes here:
+This ends up with a ``pypy-c`` or ``pypy3-c`` binary in the main pypy
+directory.  We suggest to use virtualenv with the resulting
+pypy-c/pypy3-c as the interpreter; you can find more details about
+various installation schemes here:
 
 http://doc.pypy.org/en/latest/install.html
diff --git a/pypy/doc/release-v5.7.0.rst b/pypy/doc/release-v5.7.0.rst
--- a/pypy/doc/release-v5.7.0.rst
+++ b/pypy/doc/release-v5.7.0.rst
@@ -2,23 +2,24 @@
 PyPy2.7 and PyPy3.5 v5.7 - two in one release
 =
 
-We have released PyPy2.7 and a beta-quality PyPy3.5 v5.7.
+We have released PyPy2.7 v5.7, and a beta-quality PyPy3.5 v5.7 (for
+Linux 64bit only at first).
 This new PyPy2.7 release includes the upstream stdlib version 2.7.13, and
-PyPy 3.5 (our first in the 3.5 series) includes the upstream stdlib version
+PyPy3.5 (our first in the 3.5 series) includes the upstream stdlib version
 3.5.3.
 
 We continue to make incremental improvements to our C-API
-compatibility layer (cpyext). PyPy2 can now import and run many c-extension
-packages, among the most notable are numpy, cython, and pandas. Performance may
+compatibility layer (cpyext). PyPy2 can now import and run many C-extension
+packages, among the most notable are Numpy, Cython, and Pandas. Performance may
 be slower than CPython, especially for frequently-called short C functions.
 Please let us know if your use case is slow, we have ideas how to make things
 faster but need real-world examples (not micro-benchmarks) of problematic code.
 
 Work proceeds at a good pace on the PyPy3.5
 version due to a grant_ from the Mozilla Foundation, hence our first 3.5.3 beta
-release. Thanks Mozilla !!! While we do not pass all tests, asyncio works and
+release. Thanks Mozilla !!! While we do not pass all tests yet, asyncio works 
and
 as `these benchmarks show`_ it already gives a nice speed bump.
-We also backported the ``f""`` formatting from 3.6 (as an expection; otherwise
+We also backported the ``f""`` formatting from 3.6 (as an exception; otherwise
 "PyPy3.5" supports the Python 3.5 language).
 
 CFFI_ has been updated to 1.10, improving an already great package for
@@ -65,7 +66,7 @@
 We also welcome developers of other `dynamic languages`_ to see what RPython
 can do for them.
 
-This release supports: 
+The PyPy 2.7 release supports: 
 
   * **x86** machines on most common operating systems
 (Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD)
@@ -80,64 +81,58 @@
 .. _`dynamic languages`: http://rpython.readthedocs.io/en/latest/examples.html
 
 Highlights of the PyPy2.7, cpyext, and RPython changes (since 5.6 released 
Nov, 2016)
-=
+=
 
 See also issues that were resolved_
 
 * New features and cleanups
 
   * update the format of the PYPYLOG file and improvements to vmprof
-  * improve the consistency of RPython annotation unions
   * emit more sysconfig values for downstream cextension packages
-  * add PyAnySet_Check, PyModule_GetName, PyWeakref_Check*,
-_PyImport_{Acquire,Release}Lock, PyGen_Check*, PyOS_AfterFork,
-  * add translation option --keepgoing to continue after the first 
AnnotationError
+  * add ``PyAnySet_Check``, ``PyModule_GetName``, ``PyWeakref_Check*``,
+``_PyImport_{Acquire,Release}Lock``, ``PyGen_Check*``, ``PyOS_AfterFork``,
   * detect and raise on recreation of a PyPy object from a PyObject during
 tp_dealloc
   * refactor and clean up poor handling of unicode exposed in work on py3.5
-  * builtin cppyy_ supports C++ 11, 14, etc. via cling (reflex has been 
removed)
-  * add translation time --disable_entrypoints option for embedding PyPy 
together
-with another RPython VM
-  * adapt ``weakref`` according to Python issue #19542, will be in CPython 
2.7.14
+  * builtin module cppyy_ supports C++ 11, 14, etc. via cling (reflex has been 
removed)
+  * adapt ``weakref`` according to CPython issue #19542_, will be in CPython 
2.7.14
   * support translations with cpyext and the Boehm GC (for special cases 

[pypy-commit] pypy py3.5: merge default into py3.5

2017-03-16 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r90722:702d82ab8269
Date: 2017-03-16 14:42 +0200
http://bitbucket.org/pypy/pypy/changeset/702d82ab8269/

Log:merge default into py3.5

diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py
--- a/lib_pypy/cffi/cparser.py
+++ b/lib_pypy/cffi/cparser.py
@@ -803,6 +803,16 @@
"the actual array length in this context"
% exprnode.coord.line)
 #
+if (isinstance(exprnode, pycparser.c_ast.BinaryOp) and
+exprnode.op == '+'):
+return (self._parse_constant(exprnode.left) +
+self._parse_constant(exprnode.right))
+#
+if (isinstance(exprnode, pycparser.c_ast.BinaryOp) and
+exprnode.op == '-'):
+return (self._parse_constant(exprnode.left) -
+self._parse_constant(exprnode.right))
+#
 raise FFIError(":%d: unsupported expression: expected a "
"simple numeric constant" % exprnode.coord.line)
 
diff --git a/pypy/doc/config/translation.gcrootfinder.txt 
b/pypy/doc/config/translation.gcrootfinder.txt
--- a/pypy/doc/config/translation.gcrootfinder.txt
+++ b/pypy/doc/config/translation.gcrootfinder.txt
@@ -9,10 +9,8 @@
 - ``--gcrootfinder=asmgcc``: use assembler hackery to find the
   roots directly from the normal stack.  This is a bit faster,
   but platform specific.  It works so far with GCC or MSVC,
-  on i386 and x86-64.  It is tested only on Linux (where it is
-  the default) so other platforms (as well as MSVC) may need
-  various fixes before they can be used.
+  on i386 and x86-64.  It is tested only on Linux 
+  so other platforms (as well as MSVC) may need
+  various fixes before they can be used. Note asmgcc will be deprecated
+  at some future date, and does not work with clang.
 
-You may have to force the use of the shadowstack root finder if
-you are running into troubles or if you insist on translating
-PyPy with other compilers like clang.
diff --git a/pypy/doc/release-v5.7.0.rst b/pypy/doc/release-v5.7.0.rst
--- a/pypy/doc/release-v5.7.0.rst
+++ b/pypy/doc/release-v5.7.0.rst
@@ -24,6 +24,12 @@
 CFFI_ has been updated to 1.10, improving an already great package for
 interfacing with C.
 
+We now use shadowstack as our default gcrootfinder_ even on Linux. The
+alternative, asmgcc, will be deprecated at some future point. While about 3%
+slower, shadowstack is much more easily maintained and debuggable. Also,
+the performance of shadowstack has been improved in general: this should
+close the speed gap between Linux and other platforms.
+
 As always, this release fixed many issues and bugs raised by the
 growing community of PyPy users. We strongly recommend updating.
 
@@ -47,6 +53,7 @@
 .. _`modules`: project-ideas.html#make-more-python-modules-pypy-friendly
 .. _`help`: project-ideas.html
 .. _`these benchmarks show`: 
https://morepypy.blogspot.com/2017/03/async-http-benchmarks-on-pypy3.html
+.. _gcrootfinder: config/translation.gcrootfinder.html
 
 What is PyPy?
 =
diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h 
b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
--- a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h
@@ -201,10 +201,13 @@
 
 #define BEGIN_MAPPINGS_LIST /* empty */
 #define MAPPING_ENCONLY(enc)\
+  RPY_EXTERN const struct dbcs_map pypy_cjkmap_##enc;   \
   const struct dbcs_map pypy_cjkmap_##enc = {#enc, (void*)enc##_encmap, NULL};
 #define MAPPING_DECONLY(enc)\
+  RPY_EXTERN const struct dbcs_map pypy_cjkmap_##enc;   \
   const struct dbcs_map pypy_cjkmap_##enc = {#enc, NULL, (void*)enc##_decmap};
 #define MAPPING_ENCDEC(enc) \
+  RPY_EXTERN const struct dbcs_map pypy_cjkmap_##enc;   \
   const struct dbcs_map pypy_cjkmap_##enc = {#enc, (void*)enc##_encmap, \
  (void*)enc##_decmap};
 #define END_MAPPINGS_LIST /* empty */
@@ -294,7 +297,7 @@
 
 #ifdef USING_IMPORTED_MAPS
 #define USING_IMPORTED_MAP(charset) \
-  extern const struct dbcs_map pypy_cjkmap_##charset;
+  RPY_EXTERN const struct dbcs_map pypy_cjkmap_##charset;
 
 #define IMPORT_MAP(locale, charset, encmap, decmap) \
   importmap(&pypy_cjkmap_##charset, encmap, decmap)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py 
b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py
@@ -387,13 +387,14 @@
 def test_enum():
 ffi = FFI()
 ffi.cdef("""
-enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1};
+enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1,

[pypy-commit] pypy py3.5: merge default

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89446:596ff2168cf5
Date: 2017-01-09 17:01 +0100
http://bitbucket.org/pypy/pypy/changeset/596ff2168cf5/

Log:merge default

diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -14,7 +14,7 @@
 #assert api.PyObject_CheckBuffer(w_hello)
 w_view = from_ref(space, api.PyMemoryView_FromObject(w_hello))
 w_char = space.call_method(w_view, '__getitem__', space.wrap(0))
-assert space.eq_w(w_char, space.wrap('h'))
+assert space.eq_w(w_char, space.wrap(ord('h')))
 w_bytes = space.call_method(w_view, "tobytes")
 assert space.unwrap(w_bytes) == "hello"
 
diff --git a/pypy/objspace/std/test/test_memoryobject.py 
b/pypy/objspace/std/test/test_memoryobject.py
--- a/pypy/objspace/std/test/test_memoryobject.py
+++ b/pypy/objspace/std/test/test_memoryobject.py
@@ -185,9 +185,9 @@
 assert m[2] == 1
 
 def test_pypy_raw_address_base(self):
-a = memoryview("foobar")._pypy_raw_address()
+a = memoryview(b"foobar")._pypy_raw_address()
 assert a != 0
-b = memoryview(bytearray("foobar"))._pypy_raw_address()
+b = memoryview(bytearray(b"foobar"))._pypy_raw_address()
 assert b != 0
 
 def test_hex(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default

2016-10-24 Thread pjenvey
Author: Philip Jenvey 
Branch: py3.5
Changeset: r87926:4b269804d362
Date: 2016-10-24 21:40 -0700
http://bitbucket.org/pypy/pypy/changeset/4b269804d362/

Log:merge default

diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -29,7 +29,7 @@
 class deque(object):
 
 def __new__(cls, iterable=(), *args, **kw):
-self = super(deque, cls).__new__(cls, *args, **kw)
+self = super(deque, cls).__new__(cls)
 self.clear()
 return self
 
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -228,7 +228,7 @@
 class StructOrUnion(_CData, metaclass=StructOrUnionMeta):
 
 def __new__(cls, *args, **kwds):
-self = super(_CData, cls).__new__(cls, *args, **kwds)
+self = super(_CData, cls).__new__(cls)
 if '_abstract_' in cls.__dict__:
 raise TypeError("abstract class")
 if hasattr(cls, '_ffistruct_'):
diff --git a/pypy/doc/install.rst b/pypy/doc/install.rst
--- a/pypy/doc/install.rst
+++ b/pypy/doc/install.rst
@@ -1,8 +1,17 @@
 Downloading and Installing PyPy
 ===
 
+Using a packaged PyPy
+~
+
+Some Linux distributions provide a pypy package. Note that in order to
+install additional modules that require compilation, you may need to install
+additional packages such as pypy-dev. This will manifest as an error about
+"missing Python.h". Distributions do not as of yet supply many pypy-ready
+packages, if you require additional modules we recommend creating a virtualenv
+and using pip. 
+
 .. _prebuilt-pypy:
-
 Download a pre-built PyPy
 ~
 
@@ -38,6 +47,9 @@
 and not move the binary there, else PyPy would not be able to find its
 library.
 
+Installing more modules
+~~~
+
 If you want to install 3rd party libraries, the most convenient way is
 to install pip_ using ensurepip_ (unless you want to install virtualenv as 
 explained below; then you can directly use pip inside virtualenvs):
diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -91,11 +91,17 @@
 from pypy.objspace.std.typeobject import _precheck_for_new
 w_type = _precheck_for_new(space, w_type)
 
-# don't allow arguments if the default object.__init__() is about
-# to be called
 if _excess_args(__args__):
+w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
 w_parent_init, _ = space.lookup_in_type_where(w_type, '__init__')
-if w_parent_init is space.w_object:
+if (w_parent_new is not space.w_object and
+w_parent_init is not space.w_object):
+# 2.7: warn about excess arguments when both methods are
+# overridden
+space.warn(space.wrap("object() takes no parameters"),
+   space.w_DeprecationWarning, 1)
+elif (w_parent_new is not space.w_object or
+  w_parent_init is space.w_object):
 raise oefmt(space.w_TypeError,
 "object() takes no parameters")
 if w_type.is_abstract():
@@ -108,7 +114,6 @@
 
 
 def descr__init__(space, w_obj, __args__):
-# don't allow arguments unless __new__ is overridden
 if _excess_args(__args__):
 w_type = space.type(w_obj)
 w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default

2016-10-16 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r87822:de28967a7dde
Date: 2016-10-16 09:22 +0200
http://bitbucket.org/pypy/pypy/changeset/de28967a7dde/

Log:merge default

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -2306,6 +2306,7 @@
 
 _pipe2_syscall = ENoSysCache()
 
+post_include_bits=['int _cpu_count(void);']
 # cpu count for linux, windows and mac (+ bsds)
 # note that the code is copied from cpython and split up here
 if sys.platform.startswith('linux'):
@@ -2314,7 +2315,7 @@
 RPY_EXTERN int _cpu_count(void) {
 return sysconf(_SC_NPROCESSORS_ONLN);
 }
-"""])
+"""], post_include_bits=post_include_bits)
 elif sys.platform == "win32":
 cpucount_eci = ExternalCompilationInfo(includes=["Windows.h"],
 separate_module_sources=["""
@@ -2323,7 +2324,7 @@
 GetSystemInfo(&sysinfo);
 return sysinfo.dwNumberOfProcessors;
 }
-"""])
+"""], post_include_bits=post_include_bits)
 else:
 cpucount_eci = ExternalCompilationInfo(includes=["sys/types.h", 
"sys/sysctl.h"],
 separate_module_sources=["""
@@ -2343,7 +2344,7 @@
 #endif
 return ncpu;
 }
-"""])
+"""], post_include_bits=post_include_bits)
 
 _cpu_count = rffi.llexternal('_cpu_count', [], rffi.INT_real,
 compilation_info=cpucount_eci)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge default

2016-10-13 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r87753:2373643d6613
Date: 2016-10-13 15:34 +0200
http://bitbucket.org/pypy/pypy/changeset/2373643d6613/

Log:merge default

diff --git a/lib-python/2.7/test/test_cmd_line.py 
b/lib-python/2.7/test/test_cmd_line.py
--- a/lib-python/2.7/test/test_cmd_line.py
+++ b/lib-python/2.7/test/test_cmd_line.py
@@ -75,7 +75,7 @@
 p.stdin.write('Timer\n')
 p.stdin.write('exit()\n')
 data = kill_python(p)
-self.assertTrue(data.startswith('1 loop'))
+self.assertIn('1 loop', data)
 self.assertIn('__main__.Timer', data)
 
 def test_run_code(self):
diff --git a/lib-python/2.7/test/test_timeit.py 
b/lib-python/2.7/test/test_timeit.py
--- a/lib-python/2.7/test/test_timeit.py
+++ b/lib-python/2.7/test/test_timeit.py
@@ -318,9 +318,8 @@
 s = self.run_main(seconds_per_increment=2.0, switches=['-n35', '-s', 
'print("CustomSetup")'])
 self.assertIn(dedent("""\
 WARNING: timeit is a very unreliable tool. use perf or something 
else for real measurements
-pypy -m pip install perf
-pypy -m perf timeit -n35 -s 'print("CustomSetup")' 'import timeit; 
timeit._fake_timer.inc()'
 """), s)
+self.assertIn("-m pip install perf", s)
 
 
 
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -64,8 +64,6 @@
 
 def setitem_str(self, w_dict, key, w_value):
 cell = self.getdictvalue_no_unwrapping(w_dict, key)
-#if (key == '__package__' or key == "__path__") and cell is not None 
and w_value is not cell:
-#print "WARNING", key, w_value, cell, self
 return self._setitem_str_cell_known(cell, w_dict, key, w_value)
 
 def _setitem_str_cell_known(self, cell, w_dict, key, w_value):
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -734,7 +734,7 @@
 modifier = resume.ResumeDataVirtualAdder(self, descr, op, self.trace,
  self.resumedata_memo)
 try:
-newboxes = modifier.finish(self, pendingfields)
+newboxes = modifier.finish(pendingfields)
 if (newboxes is not None and
 len(newboxes) > self.metainterp_sd.options.failargs_limit):
 raise resume.TagOverflow
diff --git a/rpython/jit/metainterp/optimizeopt/shortpreamble.py 
b/rpython/jit/metainterp/optimizeopt/shortpreamble.py
--- a/rpython/jit/metainterp/optimizeopt/shortpreamble.py
+++ b/rpython/jit/metainterp/optimizeopt/shortpreamble.py
@@ -74,13 +74,13 @@
 descr = self.getfield_op.getdescr()
 if rop.is_getfield(g.opnum):
 cf = optheap.field_cache(descr)
-opinfo.setfield(preamble_op.getdescr(), self.res, pop,
+opinfo.setfield(preamble_op.getdescr(), g.getarg(0), pop,
 optheap, cf)
 else:
 index = g.getarg(1).getint()
 assert index >= 0
 cf = optheap.arrayitem_cache(descr, index)
-opinfo.setitem(self.getfield_op.getdescr(), index, self.res,
+opinfo.setitem(self.getfield_op.getdescr(), index, g.getarg(0),
pop, optheap, cf)
 
 def repr(self, memo):
diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py
--- a/rpython/jit/metainterp/resume.py
+++ b/rpython/jit/metainterp/resume.py
@@ -165,7 +165,7 @@
 class NumberingState(object):
 def __init__(self, size):
 self.liveboxes = {}
-self.current = [0] * size
+self.current = [rffi.cast(rffi.SHORT, 0)] * size
 self._pos = 0
 self.num_boxes = 0
 self.num_virtuals = 0
@@ -179,6 +179,9 @@
 assert rffi.cast(lltype.Signed, short) == item
 return self.append_short(short)
 
+def create_numbering(self):
+return resumecode.create_numbering(self.current)
+
 class ResumeDataLoopMemo(object):
 
 def __init__(self, metainterp_sd):
@@ -229,12 +232,12 @@
 
 # env numbering
 
-def _number_boxes(self, iter, arr, optimizer, state):
+def _number_boxes(self, iter, arr, optimizer, numb_state):
 """ Number boxes from one snapshot
 """
-num_boxes = state.num_boxes
-num_virtuals = state.num_virtuals
-liveboxes = state.liveboxes
+num_boxes = numb_state.num_boxes
+num_virtuals = numb_state.num_virtuals
+liveboxes = numb_state.liveboxes
 for item in arr:
 box = iter.get(rffi.cast(lltype.Signed, item))
 box = optimizer.get_box_replacement(box)
@@ -258,34 +261,34 @@
 tagged = tag(num_boxes, TAGBOX)
 num_boxes += 1
 liveboxes[box] = tagged
-