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

2019-02-17 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r96040:d6a918e4c217
Date: 2019-02-17 13:39 +0100
http://bitbucket.org/pypy/pypy/changeset/d6a918e4c217/

Log:merge py3.5

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
@@ -100,6 +100,34 @@
 return w_item
 
 
+class W_FastUnicodeIterObject(W_AbstractSeqIterObject):
+"""Sequence iterator specialized for unicode objects."""
+
+def __init__(self, w_seq):
+from pypy.objspace.std.unicodeobject import W_UnicodeObject
+W_AbstractSeqIterObject.__init__(self, w_seq)
+assert isinstance(w_seq, W_UnicodeObject)
+self.byteindex = 0
+
+def descr_next(self, space):
+from pypy.objspace.std.unicodeobject import W_UnicodeObject
+from rpython.rlib import rutf8
+w_seq = self.w_seq
+if w_seq is None:
+raise OperationError(space.w_StopIteration, space.w_None)
+assert isinstance(w_seq, W_UnicodeObject)
+index = self.index
+if index == w_seq._length:
+self.w_seq = None
+raise OperationError(space.w_StopIteration, space.w_None)
+start = self.byteindex
+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
+
+
 class W_FastTupleIterObject(W_AbstractSeqIterObject):
 """Sequence iterator specialized for tuples, accessing directly
 their RPython-level list of wrapped objects.
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -26,6 +26,7 @@
 from pypy.objspace.std.intobject import (
 W_AbstractIntObject, W_IntObject, setup_prebuilt, wrapint)
 from pypy.objspace.std.iterobject import W_AbstractSeqIterObject, 
W_SeqIterObject
+from pypy.objspace.std.iterobject import W_FastUnicodeIterObject
 from pypy.objspace.std.listobject import W_ListObject
 from pypy.objspace.std.longobject import W_LongObject, newlong
 from pypy.objspace.std.memoryobject import W_MemoryView
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
@@ -38,6 +38,19 @@
 space.w_unicode, "__new__", space.w_unicode, w_uni)
 assert w_new is w_uni
 
+def test_fast_iter(self):
+space = self.space
+w_uni = space.newutf8(u"a".encode("utf-8"), 2)
+old_index_storage = w_uni._index_storage
+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))
+
+
 if HAS_HYPOTHESIS:
 @given(strategies.text(), strategies.integers(min_value=0, 
max_value=10),
   strategies.integers(min_value=-1, 
max_value=10))
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -93,6 +93,10 @@
 def listview_utf8(self):
 return _create_list_from_unicode(self._utf8)
 
+def descr_iter(self, space):
+from pypy.objspace.std.iterobject import W_FastUnicodeIterObject
+return W_FastUnicodeIterObject(self)
+
 def ord(self, space):
 if self._len() != 1:
 raise oefmt(space.w_TypeError,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


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

2019-02-15 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r96014:b2fbc6986462
Date: 2019-02-15 12:23 +0200
http://bitbucket.org/pypy/pypy/changeset/b2fbc6986462/

Log:merge py3.5 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.6: merge py3.5 into branch

2019-02-13 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r96009:9a4153f0307e
Date: 2019-02-14 00:39 +0200
http://bitbucket.org/pypy/pypy/changeset/9a4153f0307e/

Log:merge py3.5 into branch

diff too long, truncating to 2000 out of 27730 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -58,3 +58,12 @@
 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
+9112c8071614108b1042bfef0713915107004d62 release-pypy2.7-v7.0.0
+c8805ee6d7846ca2722b106eeaa2f128c699aba3 release-pypy2.7-v7.0.0
+1f86f25937b6ae6c8b25236c35228fac587678bf release-pypy3.5-v7.0.0
+928a4f70d3de7d17449456946154c5da6e600162 release-pypy3.5-v7.0.0
+dab365a465140aa79a5f3ba4db784c4af4d5c195 release-pypy3.6-v7.0.0
+fb40f7a5524c77b80e6c468e087d621610137261 release-pypy3.6-v7.0.0
diff --git a/TODO b/TODO
new file mode 100644
--- /dev/null
+++ b/TODO
@@ -0,0 +1,20 @@
+* find a better way to run "find" without creating the index storage, if one
+  if one is not already readily available (understand cost now, improve after 
merge)
+* improve performance of splitlines (CF)
+* think about cost of utf8 list strategy (CF)
+* revisit why runicode import str_decode_utf_8_impl needed instead of runicode
+  import str_decode_utf_8
+* revisit remaining places in win32 where we do utf8.decode('utf-8'), they 
should work
+  directly with utf8 (can be converted via runicode.str_decode_utf_8 as well)
+  - rutf8.utf8_encode_mbcs
+  - unicodehelper.fsencode
+  - _winreg.interp_winreg
+* remove 'assert not isinstance(*, unicode)
+* add a flag that prevents support for unicode in rpython and enable it in 
PyPy (CF, Armin)
+* convert all realunicode_w to unicode_w after we flush out all old uses of
+  unicode_w
+* review all uses of W_Unicode.text_w, right now it is exactly 
W_Unicode.utf8_w. 
+  It shoud only return valid utf8 (see 0be26dc39a59 which broke translation on
+  win32 and failed tests on linux64). Then we can use it in places like
+  _socket.interp_func.getaddrinfo instead of 
space.encode_unicode_object(w_port,
+  'utf-8', 'strict')
diff --git a/pypy/TODO b/pypy/TODO
--- a/pypy/TODO
+++ b/pypy/TODO
@@ -1,6 +1,3 @@
-...
-
-
 antocuni's older TODO:
 
 * run coverage against the parser/astbuilder/astcompiler: it's probably full of
@@ -11,3 +8,5 @@
 
 * re-enable BUILD_LIST_FROM_ARG: see the comment in astcompiler/codegen.py in
 ast.ListComp.build_container
+
+* review use of std_decode_utf8, we probably do not want to be using it
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`: 

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

2019-02-05 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r95830:33fe3b2cf186
Date: 2019-02-05 14:44 +0100
http://bitbucket.org/pypy/pypy/changeset/33fe3b2cf186/

Log:merge py3.5 into py3.6

diff too long, truncating to 2000 out of 22336 lines

diff --git a/lib-python/3/collections/__main__.py 
b/lib-python/3/collections/__main__.py
new file mode 100644
--- /dev/null
+++ b/lib-python/3/collections/__main__.py
@@ -0,0 +1,38 @@
+
+### Simple tests
+
+
+# verify that instances can be pickled
+from collections import namedtuple
+from pickle import loads, dumps
+Point = namedtuple('Point', 'x, y', True)
+p = Point(x=10, y=20)
+assert p == loads(dumps(p))
+
+# test and demonstrate ability to override methods
+class Point(namedtuple('Point', 'x y')):
+__slots__ = ()
+@property
+def hypot(self):
+return (self.x ** 2 + self.y ** 2) ** 0.5
+def __str__(self):
+return 'Point: x=%6.3f  y=%6.3f  hypot=%6.3f' % (self.x, self.y, 
self.hypot)
+
+for p in Point(3, 4), Point(14, 5/7.):
+print (p)
+
+class Point(namedtuple('Point', 'x y')):
+'Point class with optimized _make() and _replace() without error-checking'
+__slots__ = ()
+_make = classmethod(tuple.__new__)
+def _replace(self, _map=map, **kwds):
+return self._make(_map(kwds.get, ('x', 'y'), self))
+
+print(Point(11, 22)._replace(x=100))
+
+Point3D = namedtuple('Point3D', Point._fields + ('z',))
+print(Point3D.__doc__)
+
+import doctest, collections
+TestResults = namedtuple('TestResults', 'failed attempted')
+print(TestResults(*doctest.testmod(collections)))
diff --git a/lib-python/3/idlelib/AutoCompleteWindow.py 
b/lib-python/3/idlelib/AutoCompleteWindow.py
new file mode 100644
--- /dev/null
+++ b/lib-python/3/idlelib/AutoCompleteWindow.py
@@ -0,0 +1,416 @@
+"""
+An auto-completion window for IDLE, used by the AutoComplete extension
+"""
+from tkinter import *
+from idlelib.MultiCall import MC_SHIFT
+from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
+
+HIDE_VIRTUAL_EVENT_NAME = "<>"
+HIDE_SEQUENCES = ("", "")
+KEYPRESS_VIRTUAL_EVENT_NAME = "<>"
+# We need to bind event beyond  so that the function will be called
+# before the default specific IDLE function
+KEYPRESS_SEQUENCES = ("", "", "", "",
+  "", "", "", "",
+  "", "")
+KEYRELEASE_VIRTUAL_EVENT_NAME = "<>"
+KEYRELEASE_SEQUENCE = ""
+LISTUPDATE_SEQUENCE = ""
+WINCONFIG_SEQUENCE = ""
+DOUBLECLICK_SEQUENCE = ""
+
+class AutoCompleteWindow:
+
+def __init__(self, widget):
+# The widget (Text) on which we place the AutoCompleteWindow
+self.widget = widget
+# The widgets we create
+self.autocompletewindow = self.listbox = self.scrollbar = None
+# The default foreground and background of a selection. Saved because
+# they are changed to the regular colors of list items when the
+# completion start is not a prefix of the selected completion
+self.origselforeground = self.origselbackground = None
+# The list of completions
+self.completions = None
+# A list with more completions, or None
+self.morecompletions = None
+# The completion mode. Either AutoComplete.COMPLETE_ATTRIBUTES or
+# AutoComplete.COMPLETE_FILES
+self.mode = None
+# The current completion start, on the text box (a string)
+self.start = None
+# The index of the start of the completion
+self.startindex = None
+# The last typed start, used so that when the selection changes,
+# the new start will be as close as possible to the last typed one.
+self.lasttypedstart = None
+# Do we have an indication that the user wants the completion window
+# (for example, he clicked the list)
+self.userwantswindow = None
+# event ids
+self.hideid = self.keypressid = self.listupdateid = self.winconfigid \
+= self.keyreleaseid = self.doubleclickid = None
+# Flag set if last keypress was a tab
+self.lastkey_was_tab = False
+
+def _change_start(self, newstart):
+min_len = min(len(self.start), len(newstart))
+i = 0
+while i < min_len and self.start[i] == newstart[i]:
+i += 1
+if i < len(self.start):
+self.widget.delete("%s+%dc" % (self.startindex, i),
+   "%s+%dc" % (self.startindex, len(self.start)))
+if i < len(newstart):
+self.widget.insert("%s+%dc" % (self.startindex, i),
+   newstart[i:])
+self.start = newstart
+
+def _binary_search(self, s):
+"""Find the first index in self.completions where completions[i] is
+greater or equal to s, or the last index if there is no such
+

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

2019-01-28 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r95739:614f05464dbb
Date: 2019-01-28 16:22 +0200
http://bitbucket.org/pypy/pypy/changeset/614f05464dbb/

Log:merge py3.5 into branch

diff too long, truncating to 2000 out of 2143 lines

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
@@ -325,19 +325,32 @@
 a = array.array('H', [1, 2, 3])
 c = ffi.from_buffer(a)
 assert ffi.typeof(c) is ffi.typeof("char[]")
+assert len(c) == 6
 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("char[]", a, True)
 assert c == ffi.from_buffer(a, require_writable=True)
 #
+c = ffi.from_buffer("unsigned short[]", a)
+assert len(c) == 3
+assert c[1] == 20500
+#
 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)
+assert p == ffi.from_buffer(b"abcd", require_writable=False)
+py.test.raises((TypeError, BufferError), ffi.from_buffer,
+ "char[]", b"abcd", True)
 py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
  require_writable=True)
 
+def test_release(self):
+ffi = FFI()
+p = ffi.new("int[]", 123)
+ffi.release(p)
+# here, reading p[0] might give garbage or segfault...
+ffi.release(p)   # no effect
+
 def test_memmove(self):
 ffi = FFI()
 p = ffi.new("short[]", [-1234, -2345, -3456, -4567, -5678])
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
@@ -239,19 +239,31 @@
 def test_ffi_from_buffer():
 import array
 ffi = _cffi1_backend.FFI()
-a = array.array('H', [1, 2, 3])
+a = array.array('H', [1, 2, 3, 4])
 c = ffi.from_buffer(a)
 assert ffi.typeof(c) is ffi.typeof("char[]")
+assert len(c) == 8
 ffi.cast("unsigned short *", c)[1] += 500
-assert list(a) == [1, 20500, 3]
-assert c == ffi.from_buffer(a, True)
+assert list(a) == [1, 20500, 3, 4]
+py.test.raises(TypeError, ffi.from_buffer, a, True)
+assert c == ffi.from_buffer("char[]", a, True)
 assert c == ffi.from_buffer(a, require_writable=True)
 #
+c = ffi.from_buffer("unsigned short[]", a)
+assert len(c) == 4
+assert c[1] == 20500
+#
+c = ffi.from_buffer("unsigned short[2][2]", a)
+assert len(c) == 2
+assert len(c[0]) == 2
+assert c[0][1] == 20500
+#
 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)
+assert p == ffi.from_buffer(b"abcd", require_writable=False)
+py.test.raises((TypeError, BufferError), ffi.from_buffer,
+ "char[]", b"abcd", True)
 py.test.raises((TypeError, BufferError), ffi.from_buffer, b"abcd",
  require_writable=True)
 
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
@@ -1457,6 +1457,35 @@
 import gc; gc.collect(); gc.collect(); gc.collect()
 assert seen == [3]
 
+def test_release(self):
+p = ffi.new("int[]", 123)
+ffi.release(p)
+# here, reading p[0] might give garbage or segfault...
+ffi.release(p)   # no effect
+
+def test_release_new_allocator(self):
+seen = []
+def myalloc(size):
+seen.append(size)
+return ffi.new("char[]", b"X" * size)
+def myfree(raw):
+seen.append(raw)
+alloc2 = ffi.new_allocator(alloc=myalloc, free=myfree)
+p = alloc2("int[]", 15)
+assert seen == [15 * 4]
+ffi.release(p)
+assert seen == [15 * 4, p]
+ffi.release(p)# no effect
+assert seen == [15 * 4, p]
+#
+del seen[:]
+p = alloc2("struct ab *")
+assert seen == [2 * 4]
+ffi.release(p)
+assert seen == [2 * 4, p]
+ffi.release(p)# no effect
+assert seen == [2 * 4, p]
+
 def test_CData_CType(self):
 assert isinstance(ffi.cast("int", 0), ffi.CData)
 assert isinstance(ffi.new("int *"), 

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

2018-12-16 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r95503:df88cbf79dc7
Date: 2018-12-16 17:02 +0100
http://bitbucket.org/pypy/pypy/changeset/df88cbf79dc7/

Log:merge py3.5

diff too long, truncating to 2000 out of 9468 lines

diff --git a/extra_tests/cffi_tests/cffi1/test_recompiler.py 
b/extra_tests/cffi_tests/cffi1/test_recompiler.py
--- a/extra_tests/cffi_tests/cffi1/test_recompiler.py
+++ b/extra_tests/cffi_tests/cffi1/test_recompiler.py
@@ -5,7 +5,7 @@
 from cffi import recompiler
 from extra_tests.cffi_tests.udir import udir
 from extra_tests.cffi_tests.support import u, long
-from extra_tests.cffi_tests.support import FdWriteCapture, StdErrCapture
+from extra_tests.cffi_tests.support import FdWriteCapture, StdErrCapture, 
_verify
 
 try:
 import importlib
@@ -36,7 +36,7 @@
 # add '-Werror' to the existing 'extra_compile_args' flags
 kwds['extra_compile_args'] = (kwds.get('extra_compile_args', []) +
   ['-Werror'])
-return recompiler._verify(ffi, module_name, source, *args, **kwds)
+return _verify(ffi, module_name, source, *args, **kwds)
 
 def test_set_source_no_slashes():
 ffi = FFI()
@@ -1539,15 +1539,18 @@
 assert (pt.x, pt.y) == (99*500*999, -99*500*999)
 
 def test_extern_python_1():
+import warnings
 ffi = FFI()
-ffi.cdef("""
+with warnings.catch_warnings(record=True) as log:
+ffi.cdef("""
 extern "Python" {
 int bar(int, int);
 void baz(int, int);
 int bok(void);
 void boz(void);
 }
-""")
+""")
+assert len(log) == 0, "got a warning: %r" % (log,)
 lib = verify(ffi, 'test_extern_python_1', """
 static void baz(int, int);   /* forward */
 """)
diff --git a/extra_tests/cffi_tests/cffi1/test_verify1.py 
b/extra_tests/cffi_tests/cffi1/test_verify1.py
--- a/extra_tests/cffi_tests/cffi1/test_verify1.py
+++ b/extra_tests/cffi_tests/cffi1/test_verify1.py
@@ -4,6 +4,7 @@
 from cffi import CDefError
 from cffi import recompiler
 from extra_tests.cffi_tests.support import *
+from extra_tests.cffi_tests.support import _verify
 import _cffi_backend
 
 lib_m = ['m']
@@ -38,9 +39,8 @@
 except AttributeError:
 pass
 self.set_source(module_name, preamble)
-return recompiler._verify(self, module_name, preamble, *args,
-  extra_compile_args=self._extra_compile_args,
-  **kwds)
+return _verify(self, module_name, preamble, *args,
+   extra_compile_args=self._extra_compile_args, **kwds)
 
 class FFI_warnings_not_error(FFI):
 _extra_compile_args = []
diff --git a/extra_tests/cffi_tests/support.py 
b/extra_tests/cffi_tests/support.py
--- a/extra_tests/cffi_tests/support.py
+++ b/extra_tests/cffi_tests/support.py
@@ -62,3 +62,28 @@
 
 def getvalue(self):
 return self._value
+
+def _verify(ffi, module_name, preamble, *args, **kwds):
+import imp
+from cffi.recompiler import recompile
+from .udir import udir
+assert module_name not in sys.modules, "module name conflict: %r" % (
+module_name,)
+kwds.setdefault('tmpdir', str(udir))
+outputfilename = recompile(ffi, module_name, preamble, *args, **kwds)
+module = imp.load_dynamic(module_name, outputfilename)
+#
+# hack hack hack: copy all *bound methods* from module.ffi back to the
+# ffi instance.  Then calls like ffi.new() will invoke module.ffi.new().
+for name in dir(module.ffi):
+if not name.startswith('_'):
+attr = getattr(module.ffi, name)
+if attr is not getattr(ffi, name, object()):
+setattr(ffi, name, attr)
+def typeof_disabled(*args, **kwds):
+raise NotImplementedError
+ffi._typeof = typeof_disabled
+for name in dir(ffi):
+if not name.startswith('_') and not hasattr(module.ffi, name):
+setattr(ffi, name, NotImplemented)
+return module.lib
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/__init__.py 
b/extra_tests/ctypes_tests/__init__.py
rename from pypy/module/test_lib_pypy/ctypes_tests/__init__.py
rename to extra_tests/ctypes_tests/__init__.py
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c 
b/extra_tests/ctypes_tests/_ctypes_test.c
rename from pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
rename to extra_tests/ctypes_tests/_ctypes_test.c
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py 
b/extra_tests/ctypes_tests/conftest.py
rename from pypy/module/test_lib_pypy/ctypes_tests/conftest.py
rename to extra_tests/ctypes_tests/conftest.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/conftest.py
+++ b/extra_tests/ctypes_tests/conftest.py
@@ -3,10 +3,6 @@
 import sys
 import os
 
-def pytest_ignore_collect(path):
-if '__pypy__' not in sys.builtin_module_names:
-return True
-
 # XXX: copied from pypy/tool/cpyext/extbuild.py
 if 

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

2018-12-12 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r95467:4626a6708b2b
Date: 2018-12-09 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/4626a6708b2b/

Log:merge py3.5 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")
+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/extra_tests/test_decimal.py b/extra_tests/test_decimal.py
--- a/extra_tests/test_decimal.py
+++ b/extra_tests/test_decimal.py
@@ -4,7 +4,7 @@
 import pickle
 import sys
 
-from support import import_fresh_module
+from .support import import_fresh_module
 
 C = import_fresh_module('decimal', fresh=['_decimal'])
 P = import_fresh_module('decimal', blocked=['_decimal'])
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -1542,7 +1542,7 @@
 
 def _verify(ffi, module_name, preamble, *args, **kwds):
 # FOR TESTS ONLY
-from testing.udir import udir
+from .testing.udir import udir
 import imp
 assert module_name not in sys.modules, "module name conflict: %r" % (
 module_name,)
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
@@ -55,3 +55,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
@@ -604,8 +604,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/_rawffi/alt/test/test_ffitype.py 
b/pypy/module/_rawffi/alt/test/test_ffitype.py
--- a/pypy/module/_rawffi/alt/test/test_ffitype.py
+++ b/pypy/module/_rawffi/alt/test/test_ffitype.py
@@ -1,6 +1,5 @@
-from pypy.module._rawffi.alt.test.test_funcptr import BaseAppTestFFI
-
-class AppTestFFIType(BaseAppTestFFI):
+class AppTestFFIType(object):
+spaceconfig = dict(usemodules=('_rawffi',))
 
 def test_simple_types(self):
 from _rawffi.alt import types
@@ -8,7 +7,7 @@
 assert str(types.uint) == ""
 assert types.sint.name == 'sint'
 assert types.uint.name == 'uint'
-

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

2018-11-18 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r95343:dd77cb64ae34
Date: 2018-11-18 21:12 -0800
http://bitbucket.org/pypy/pypy/changeset/dd77cb64ae34/

Log:merge py3.5 into branch

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
@@ -539,7 +539,7 @@
 elif space.isinstance_w(w_obj, space.w_bytearray):   # Python 2.x specific
 raise oefmt(space.w_TypeError, "decoding bytearray is not supported")
 else:
-s = space.buffer_w(w_obj, 0)
+s = space.charbuf_w(w_obj)
 return _pyunicode_decode(space, s, encoding, errors)
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


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

2018-11-18 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r95332:fb5a5a9969b0
Date: 2018-11-18 00:56 -0800
http://bitbucket.org/pypy/pypy/changeset/fb5a5a9969b0/

Log:merge py3.5 into branch

diff --git a/extra_tests/__init__.py b/extra_tests/__init__.py
new file mode 100644
diff --git a/pypy/module/test_lib_pypy/cffi_tests/__init__.py 
b/extra_tests/cffi_tests/__init__.py
rename from pypy/module/test_lib_pypy/cffi_tests/__init__.py
rename to extra_tests/cffi_tests/__init__.py
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/__init__.py 
b/extra_tests/cffi_tests/cffi0/__init__.py
rename from pypy/module/test_lib_pypy/cffi_tests/cffi0/__init__.py
rename to extra_tests/cffi_tests/cffi0/__init__.py
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py 
b/extra_tests/cffi_tests/cffi0/backend_tests.py
rename from pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
rename to extra_tests/cffi_tests/cffi0/backend_tests.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/backend_tests.py
+++ b/extra_tests/cffi_tests/cffi0/backend_tests.py
@@ -3,7 +3,7 @@
 import platform
 import sys, ctypes
 from cffi import FFI, CDefError, FFIError, VerificationMissing
-from pypy.module.test_lib_pypy.cffi_tests.support import *
+from extra_tests.cffi_tests.support import *
 
 SIZE_OF_INT   = ctypes.sizeof(ctypes.c_int)
 SIZE_OF_LONG  = ctypes.sizeof(ctypes.c_long)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/callback_in_thread.py 
b/extra_tests/cffi_tests/cffi0/callback_in_thread.py
rename from pypy/module/test_lib_pypy/cffi_tests/cffi0/callback_in_thread.py
rename to extra_tests/cffi_tests/cffi0/callback_in_thread.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_module/setup.py 
b/extra_tests/cffi_tests/cffi0/snippets/distutils_module/setup.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_module/setup.py
rename to extra_tests/cffi_tests/cffi0/snippets/distutils_module/setup.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_module/snip_basic_verify.py
 b/extra_tests/cffi_tests/cffi0/snippets/distutils_module/snip_basic_verify.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_module/snip_basic_verify.py
rename to 
extra_tests/cffi_tests/cffi0/snippets/distutils_module/snip_basic_verify.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_1/setup.py
 b/extra_tests/cffi_tests/cffi0/snippets/distutils_package_1/setup.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_1/setup.py
rename to extra_tests/cffi_tests/cffi0/snippets/distutils_package_1/setup.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_1/snip_basic_verify1/__init__.py
 
b/extra_tests/cffi_tests/cffi0/snippets/distutils_package_1/snip_basic_verify1/__init__.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_1/snip_basic_verify1/__init__.py
rename to 
extra_tests/cffi_tests/cffi0/snippets/distutils_package_1/snip_basic_verify1/__init__.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_2/setup.py
 b/extra_tests/cffi_tests/cffi0/snippets/distutils_package_2/setup.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_2/setup.py
rename to extra_tests/cffi_tests/cffi0/snippets/distutils_package_2/setup.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_2/snip_basic_verify2/__init__.py
 
b/extra_tests/cffi_tests/cffi0/snippets/distutils_package_2/snip_basic_verify2/__init__.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/distutils_package_2/snip_basic_verify2/__init__.py
rename to 
extra_tests/cffi_tests/cffi0/snippets/distutils_package_2/snip_basic_verify2/__init__.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/infrastructure/setup.py 
b/extra_tests/cffi_tests/cffi0/snippets/infrastructure/setup.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/infrastructure/setup.py
rename to extra_tests/cffi_tests/cffi0/snippets/infrastructure/setup.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/infrastructure/snip_infrastructure/__init__.py
 
b/extra_tests/cffi_tests/cffi0/snippets/infrastructure/snip_infrastructure/__init__.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/infrastructure/snip_infrastructure/__init__.py
rename to 
extra_tests/cffi_tests/cffi0/snippets/infrastructure/snip_infrastructure/__init__.py
diff --git 
a/pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/setuptools_module/setup.py
 b/extra_tests/cffi_tests/cffi0/snippets/setuptools_module/setup.py
rename from 
pypy/module/test_lib_pypy/cffi_tests/cffi0/snippets/setuptools_module/setup.py
rename to extra_tests/cffi_tests/cffi0/snippets/setuptools_module/setup.py
diff --git 

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

2018-11-18 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r95329:18106031c176
Date: 2018-11-17 23:33 -0800
http://bitbucket.org/pypy/pypy/changeset/18106031c176/

Log:merge py3.5 into branch

diff too long, truncating to 2000 out of 2161 lines

diff --git a/lib-python/3/distutils/sysconfig_pypy.py 
b/lib-python/3/distutils/sysconfig_pypy.py
--- a/lib-python/3/distutils/sysconfig_pypy.py
+++ b/lib-python/3/distutils/sysconfig_pypy.py
@@ -8,11 +8,9 @@
 available.
 """
 
-__revision__ = "$Id: sysconfig.py 85358 2010-10-10 09:54:59Z antoine.pitrou $"
-
 import sys
 import os
-import imp
+import imp, _imp
 
 from distutils.errors import DistutilsPlatformError
 
@@ -71,9 +69,17 @@
 def _init_nt():
 """Initialize the module as appropriate for NT"""
 g = {}
+# set basic install directories
+g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
+g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
+
+# XXX hmmm.. a normal install puts include files here
+g['INCLUDEPY'] = get_python_inc(plat_specific=0)
+
+g['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
 g['EXE'] = ".exe"
-g['SO'] = ".pyd"
-g['SOABI'] = g['SO'].rsplit('.')[0]   # xxx?
+g['VERSION'] = get_python_version().replace(".", "")
+g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
 
 global _config_vars
 _config_vars = g
diff --git a/lib_pypy/_cffi_ssl/_stdssl/__init__.py 
b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
@@ -190,7 +190,7 @@
 # Prefer poll, if available, since you can poll() any fd
 # which can't be done with select().
 if HAVE_POLL:
-p.register(sock.fileno(), POLLOUT | POLLIN)
+p.register(sock.fileno(), POLLOUT if writing else POLLIN)
 
 rc = len(p.poll(timeout * 1000.0))
 else:
diff --git a/lib_pypy/pyrepl/unix_console.py b/lib_pypy/pyrepl/unix_console.py
--- a/lib_pypy/pyrepl/unix_console.py
+++ b/lib_pypy/pyrepl/unix_console.py
@@ -27,6 +27,12 @@
 from .console import Console, Event
 from .unix_eventqueue import EventQueue
 from .trace import trace
+try:
+from __pypy__ import pyos_inputhook
+except ImportError:
+def pyos_inputhook():
+pass
+
 
 class InvalidTerminal(RuntimeError):
 pass
@@ -76,8 +82,8 @@
 pass
 def register(self, fd, flag):
 self.fd = fd
-def poll(self, timeout=None):
-r,w,e = select.select([self.fd],[],[],timeout)
+def poll(self):   # note: a 'timeout' argument would be *milliseconds*
+r,w,e = select.select([self.fd],[],[])
 return r
 
 POLLIN = getattr(select, "POLLIN", None)
@@ -407,6 +413,7 @@
 def get_event(self, block=1):
 while self.event_queue.empty():
 while 1: # All hail Unix!
+pyos_inputhook()
 try:
 self.push_char(os.read(self.input_fd, 1))
 except (IOError, OSError) as err:
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
@@ -42,3 +42,16 @@
 .. branch: py3.6-wordcode
 
 implement new wordcode instruction encoding on the 3.6 branch
+
+.. branch: socket_default_timeout_blockingness
+
+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/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -110,6 +110,7 @@
 'stack_almost_full' : 'interp_magic.stack_almost_full',
 'fsencode'  : 'interp_magic.fsencode',
 'fsdecode'  : 'interp_magic.fsdecode',
+'pyos_inputhook': 'interp_magic.pyos_inputhook',
 }
 
 submodules = {
diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -209,3 +209,13 @@
 def revdb_stop(space):
 from pypy.interpreter.reverse_debugging import stop_point
 stop_point()
+
+def pyos_inputhook(space):
+"""Call PyOS_InputHook() from the CPython C API."""
+if not space.config.objspace.usemodules.cpyext:
+return
+w_modules = space.sys.get('modules')
+if space.finditem_str(w_modules, 'cpyext') is None:
+return  # cpyext not imported yet, ignore
+from pypy.module.cpyext.api import invoke_pyos_inputhook
+invoke_pyos_inputhook(space)
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -79,13 +79,6 @@
 w_result 

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

2018-07-01 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r94799:289d8154d34d
Date: 2018-07-01 22:42 -0500
http://bitbucket.org/pypy/pypy/changeset/289d8154d34d/

Log:merge py3.5 into py3.6

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1287,9 +1287,11 @@
 
 def WITH_CLEANUP_FINISH(self, oparg, next_instr):
 w_suppress = self.popvalue()
-if self.space.is_true(w_suppress):
-# __exit__() returned True -> Swallow the exception.
-self.settopvalue(self.space.w_None)
+w_unroller = self.peekvalue()
+if isinstance(w_unroller, SApplicationException):
+if self.space.is_true(w_suppress):
+# __exit__() returned True -> Swallow the exception.
+self.settopvalue(self.space.w_None)
 # this is always followed by END_FINALLY
 # in the stack now: [w_unroller-or-w_None..]
 
diff --git a/pypy/interpreter/test/test_coroutine.py 
b/pypy/interpreter/test/test_coroutine.py
--- a/pypy/interpreter/test/test_coroutine.py
+++ b/pypy/interpreter/test/test_coroutine.py
@@ -130,6 +130,27 @@
 assert seen == ['aenter', 'aexit']
 """
 
+def test_async_with_exit_True(self): """
+seen = []
+class X:
+async def __aenter__(self):
+seen.append('aenter')
+async def __aexit__(self, *args):
+seen.append('aexit')
+return True
+async def f(x):
+async with x:
+return 42
+c = f(X())
+try:
+c.send(None)
+except StopIteration as e:
+assert e.value == 42
+else:
+assert False, "should have raised"
+assert seen == ['aenter', 'aexit']
+"""
+
 def test_await(self): """
 class X:
 def __await__(self):
diff --git a/pypy/interpreter/test/test_raise.py 
b/pypy/interpreter/test/test_raise.py
--- a/pypy/interpreter/test/test_raise.py
+++ b/pypy/interpreter/test/test_raise.py
@@ -309,6 +309,17 @@
 return object()
 raises(TypeError, "raise MyException")
 
+def test_with_exit_True(self):
+class X:
+def __enter__(self):
+pass
+def __exit__(self, *args):
+return True
+def g():
+with X():
+return 42
+assert False, "unreachable"
+assert g() == 42
 
 def test_pop_exception_value(self):
 # assert that this code don't crash
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


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

2018-06-30 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r94790:a43321e72438
Date: 2018-06-30 19:47 -0700
http://bitbucket.org/pypy/pypy/changeset/a43321e72438/

Log:merge py3.5 into py3.6

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/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -288,7 +288,7 @@
 if self.frame is None:
 return # nothing to do in this case
 space = self.space
-operr = get_generator_exit(space)
+operr = None
 # note: w_yielded_from is always None if 'self.running'
 w_yf = self.w_yielded_from
 if w_yf is not None:
@@ -296,6 +296,8 @@
 self._gen_close_iter(space)
 except OperationError as e:
 operr = e
+if operr is None:
+operr = OperationError(space.w_GeneratorExit, space.w_None)
 try:
 self.send_error(operr)
 except OperationError as e:
@@ -471,11 +473,6 @@
  space.call_function(space.w_StopIteration, w_value))
 
 
-@specialize.memo()
-def get_generator_exit(space):
-return OperationError(space.w_GeneratorExit,
-  space.call_function(space.w_GeneratorExit))
-
 def gen_close_iter(space, w_yf):
 # This helper function is used by close() and throw() to
 # close a subiterator being delegated to by yield-from.
diff --git a/pypy/interpreter/test/test_function.py 
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -170,6 +170,7 @@
 h = get_h()
 raises(ValueError, "f.__code__ = h.__code__")
 
+@pytest.mark.skipif("config.option.runappdirect")
 def test_write_code_builtin_forbidden(self):
 def f(*args):
 return 42
@@ -339,7 +340,6 @@
 assert meth() == obj
 
 def test_none_get_interaction(self):
-skip("XXX issue #2083")
 assert type(None).__repr__(None) == 'None'
 
 def test_none_get_interaction_2(self):
@@ -544,7 +544,9 @@
 pass
 r = repr(ClsB().f)
 assert "ClsA.f of <" in r
-assert "ClsB object at " in r
+assert repr(type(ClsA.f)) == ""
+assert repr(type(ClsA().f)) == ""
+
 
 def test_method_call(self):
 class C(object):
diff --git a/pypy/module/_cppyy/converter.py b/pypy/module/_cppyy/converter.py
--- a/pypy/module/_cppyy/converter.py
+++ b/pypy/module/_cppyy/converter.py
@@ -706,7 +706,7 @@
 "no overload found matching %s", self.signature)
 
 
-class SmartPointerConverter(TypeConverter):
+class SmartPtrConverter(TypeConverter):
 _immutable_fields = ['typecode', 'smartdecl', 'rawdecl', 'deref']
 typecode= 'V'
 
@@ -753,7 +753,7 @@
 return interp_cppyy.wrap_cppinstance(space, address,
 self.rawdecl, smartdecl=self.smartdecl, deref=self.deref, 
do_cast=False)
 
-class SmartPointerPtrConverter(SmartPointerConverter):
+class SmartPtrPtrConverter(SmartPtrConverter):
 typecode= 'o'
 
 def from_memory(self, space, w_obj, w_pycppclass, offset):
@@ -763,7 +763,7 @@
 self._is_abstract(space)
 
 
-class SmartPointerRefConverter(SmartPointerPtrConverter):
+class SmartPtrRefConverter(SmartPtrPtrConverter):
 typecode= 'V'
 
 
@@ -804,6 +804,12 @@
 compound = helper.compound(name)
 clean_name = capi.c_resolve_name(space, helper.clean_type(name))
 try:
+return _converters[clean_name+compound](space, default)
+except KeyError:
+pass
+
+# arrays
+try:
 # array_index may be negative to indicate no size or no size found
 array_size = helper.array_size(_name) # uses original arg
 # TODO: using clean_name here drops const (e.g. const char[] will
@@ -823,11 +829,11 @@
 check_smart = capi.c_smartptr_info(space, clean_name)
 if check_smart[0]:
 if compound == '':
-return SmartPointerConverter(space, clsdecl, check_smart[1], 
check_smart[2])
+return SmartPtrConverter(space, clsdecl, check_smart[1], 
check_smart[2])
 elif compound == '*':
-return SmartPointerPtrConverter(space, clsdecl, 
check_smart[1], check_smart[2])
+return SmartPtrPtrConverter(space, clsdecl, check_smart[1], 
check_smart[2])
 elif compound == '&':
-return SmartPointerRefConverter(space, clsdecl, 
check_smart[1], 

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

2018-06-08 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r94739:a2790e033e07
Date: 2018-06-08 15:50 +0200
http://bitbucket.org/pypy/pypy/changeset/a2790e033e07/

Log:merge py3.5

diff too long, truncating to 2000 out of 9430 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -33,7 +33,12 @@
 050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1
 050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1
 0e2d9a73f5a1818d0245d75daccdbe21b2d5c3ef release-pypy2.7-v5.4.1
+4909c06daf41ce88f87dc01c57959cadad4df4a8 RevDB-pypy2.7-v5.4.1
+4909c06daf41ce88f87dc01c57959cadad4df4a8 RevDB-pypy2.7-v5.4.1
+d7724c0a5700b895a47de44074cdf5fd659a988f RevDB-pypy2.7-v5.4.1
 aff251e543859ce4508159dd9f1a82a2f553de00 release-pypy2.7-v5.6.0
+e90317857d27917bf840caf675832292ee070510 RevDB-pypy2.7-v5.6.1
+a24d6c7000c8099c73d3660857f7e3cee5ac045c RevDB-pypy2.7-v5.6.2
 fa3249d55d15b9829e1be69cdf45b5a44cec902d release-pypy2.7-v5.7.0
 b16a4363e930f6401bceb499b9520955504c6cb0 release-pypy3.5-v5.7.0
 1aa2d8e03cdfab54b7121e93fda7e98ea88a30bf release-pypy2.7-v5.7.1
diff --git a/lib-python/3/opcode.py b/lib-python/3/opcode.py
--- a/lib-python/3/opcode.py
+++ b/lib-python/3/opcode.py
@@ -224,5 +224,6 @@
 def_op('CALL_METHOD', 202)# #args not including 'self'
 def_op('BUILD_LIST_FROM_ARG', 203)
 jrel_op('JUMP_IF_NOT_DEBUG', 204) # jump over assert statements
+def_op('LOAD_REVDB_VAR', 205) # reverse debugger (syntax example: $5)
 
 del def_op, name_op, jrel_op, jabs_op
diff --git a/lib_pypy/_sysconfigdata.py b/lib_pypy/_sysconfigdata.py
--- a/lib_pypy/_sysconfigdata.py
+++ b/lib_pypy/_sysconfigdata.py
@@ -24,6 +24,15 @@
 'VERSION': sys.version[:3]
 }
 
+if find_executable("gcc"):
+build_time_vars.update({
+"CC": "gcc -pthread",
+"GNULD": "yes",
+"LDSHARED": "gcc -pthread -shared",
+})
+if find_executable("g++"):
+build_time_vars["CXX"] = "g++ -pthread"
+
 if sys.platform[:6] == "darwin":
 import platform
 if platform.machine() == 'i386':
@@ -36,12 +45,6 @@
 arch = platform.machine()
 build_time_vars['LDSHARED'] += ' -undefined dynamic_lookup'
 build_time_vars['CC'] += ' -arch %s' % (arch,)
+if "CXX" in build_time_vars:
+build_time_vars['CXX'] += ' -arch %s' % (arch,)
 
-if find_executable("gcc"):
-build_time_vars.update({
-"CC": "gcc -pthread",
-"GNULD": "yes",
-"LDSHARED": "gcc -pthread -shared",
-})
-if find_executable("g++"):
-build_time_vars["CXX"] = "g++ -pthread"
diff --git a/lib_pypy/grp.py b/lib_pypy/grp.py
--- a/lib_pypy/grp.py
+++ b/lib_pypy/grp.py
@@ -5,6 +5,8 @@
 import os
 from _pwdgrp_cffi import ffi, lib
 import _structseq
+import thread
+_lock = thread.allocate_lock()
 
 try: from __pypy__ import builtinify
 except ImportError: builtinify = lambda f: f
@@ -33,37 +35,39 @@
 
 @builtinify
 def getgrgid(gid):
-try:
-res = lib.getgrgid(gid)
-except TypeError:
-gid = int(gid)
-res = lib.getgrgid(gid)
-import warnings
-warnings.warn("group id must be int", DeprecationWarning)
-if not res:
-# XXX maybe check error eventually
-raise KeyError(gid)
-return _group_from_gstruct(res)
-
+with _lock:
+try:
+res = lib.getgrgid(gid)
+except TypeError:
+gid = int(gid)
+res = lib.getgrgid(gid)
+import warnings
+warnings.warn("group id must be int", DeprecationWarning)
+if not res:
+# XXX maybe check error eventually
+raise KeyError(gid)
+return _group_from_gstruct(res)
 @builtinify
 def getgrnam(name):
 if not isinstance(name, str):
 raise TypeError("expected string")
-res = lib.getgrnam(os.fsencode(name))
-if not res:
-raise KeyError("'getgrnam(): name not found: %s'" % name)
-return _group_from_gstruct(res)
+with _lock:
+res = lib.getgrnam(os.fsencode(name))
+if not res:
+raise KeyError("'getgrnam(): name not found: %s'" % name)
+return _group_from_gstruct(res)
 
 @builtinify
 def getgrall():
-lib.setgrent()
 lst = []
-while 1:
-p = lib.getgrent()
-if not p:
-break
-lst.append(_group_from_gstruct(p))
-lib.endgrent()
+with _lock:
+lib.setgrent()
+while 1:
+p = lib.getgrent()
+if not p:
+break
+lst.append(_group_from_gstruct(p))
+lib.endgrent()
 return lst
 
 __all__ = ('struct_group', 'getgrgid', 'getgrnam', 'getgrall')
diff --git a/lib_pypy/pwd.py b/lib_pypy/pwd.py
--- a/lib_pypy/pwd.py
+++ b/lib_pypy/pwd.py
@@ -12,6 +12,8 @@
 
 from _pwdgrp_cffi import ffi, lib
 import _structseq
+import thread
+_lock = thread.allocate_lock()
 
 try: from __pypy__ import builtinify
 except ImportError: builtinify = lambda f: f
@@ -54,10 +56,11 @@
 Return the password 

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

2018-05-21 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r94618:c4057f244c87
Date: 2018-05-21 14:10 +0200
http://bitbucket.org/pypy/pypy/changeset/c4057f244c87/

Log:merge py3.5

diff --git a/pypy/interpreter/test/test_gateway.py 
b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -525,19 +525,19 @@
 w_app_g3_i = space.wrap(app_g3_i)
 assert space.eq_w(space.call_function(w_app_g3_i,w(1)),w(1))
 assert space.eq_w(space.call_function(w_app_g3_i,w(1L)),w(1))
-
raises(gateway.OperationError,space.call_function,w_app_g3_i,w(sys.maxint*2))
-raises(gateway.OperationError,space.call_function,w_app_g3_i,w(None))
-raises(gateway.OperationError,space.call_function,w_app_g3_i,w("foo"))
-raises(gateway.OperationError,space.call_function,w_app_g3_i,w(1.0))
+space.raises_w(space.w_OverflowError, 
space.call_function,w_app_g3_i,w(sys.maxint*2))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_i,w(None))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_i,w("foo"))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_i,w(1.0))
 
 app_g3_s = gateway.interp2app_temp(g3_id,
  unwrap_spec=[gateway.ObjSpace,
   'text'])
 w_app_g3_s = space.wrap(app_g3_s)
 assert space.eq_w(space.call_function(w_app_g3_s,w("foo")),w("foo"))
-raises(gateway.OperationError,space.call_function,w_app_g3_s,w(None))
-raises(gateway.OperationError,space.call_function,w_app_g3_s,w(1))
-raises(gateway.OperationError,space.call_function,w_app_g3_s,w(1.0))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_s,w(None))
+space.raises_w(space.w_TypeError, space.call_function,w_app_g3_s,w(1))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_s,w(1.0))
 
 app_g3_f = gateway.interp2app_temp(g3_id,
  unwrap_spec=[gateway.ObjSpace,
@@ -546,14 +546,14 @@
 assert space.eq_w(space.call_function(w_app_g3_f,w(1.0)),w(1.0))
 assert space.eq_w(space.call_function(w_app_g3_f,w(1)),w(1.0))
 assert space.eq_w(space.call_function(w_app_g3_f,w(1L)),w(1.0))
-raises(gateway.OperationError,space.call_function,w_app_g3_f,w(None))
-raises(gateway.OperationError,space.call_function,w_app_g3_f,w("foo"))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_f,w(None))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_f,w("foo"))
 
 app_g3_r = gateway.interp2app_temp(g3_id,
unwrap_spec=[gateway.ObjSpace,
 r_longlong])
 w_app_g3_r = space.wrap(app_g3_r)
-raises(gateway.OperationError,space.call_function,w_app_g3_r,w(1.0))
+space.raises_w(space.w_TypeError, 
space.call_function,w_app_g3_r,w(1.0))
 
 def test_interp2app_unwrap_spec_unicode(self):
 space = self.space
@@ -570,9 +570,9 @@
 assert self.space.eq_w(
 space.call_function(w_app_g3_u, w("baz")),
 w(3))
-raises(gateway.OperationError, space.call_function, w_app_g3_u,
+space.raises_w(space.w_TypeError, space.call_function, w_app_g3_u,
w(None))
-raises(gateway.OperationError, space.call_function, w_app_g3_u,
+space.raises_w(space.w_TypeError, space.call_function, w_app_g3_u,
w(42))
 
 def test_interp2app_unwrap_spec_unwrapper(self):
@@ -589,7 +589,7 @@
   Unwrapper])
 assert self.space.eq_w(
 space.call_function(w(app_g3_u), w(42)), w(43))
-raises(gateway.OperationError, space.call_function,
+space.raises_w(space.w_TypeError, space.call_function,
w(app_g3_u), w(None))
 
 def test_interp2app_classmethod(self):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


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

2018-05-16 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r94606:2a70f2b84450
Date: 2018-05-16 20:45 -0700
http://bitbucket.org/pypy/pypy/changeset/2a70f2b84450/

Log:merge py3.5 into py3.6

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


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

2018-05-16 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r94600:455b5c86ee7b
Date: 2018-05-16 14:38 +0200
http://bitbucket.org/pypy/pypy/changeset/455b5c86ee7b/

Log:merge py3.5

diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -423,6 +423,7 @@
 RegrTest('test_sys_setprofile.py', core=True),
 RegrTest('test_sys_settrace.py', core=True),
 RegrTest('test_sysconfig.py'),
+RegrTest('test_sysconfig_pypy.py'),
 RegrTest('test_syslog.py'),
 RegrTest('test_tarfile.py'),
 RegrTest('test_tcl.py'),
diff --git a/pypy/interpreter/astcompiler/test/test_validate.py 
b/pypy/interpreter/astcompiler/test/test_validate.py
--- a/pypy/interpreter/astcompiler/test/test_validate.py
+++ b/pypy/interpreter/astcompiler/test/test_validate.py
@@ -1,4 +1,5 @@
 import os
+from pytest import raises
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.astcompiler import ast
diff --git a/pypy/interpreter/test/test_app_main.py 
b/pypy/interpreter/test/test_app_main.py
--- a/pypy/interpreter/test/test_app_main.py
+++ b/pypy/interpreter/test/test_app_main.py
@@ -375,7 +375,7 @@
 child.expect('>>>')
 
 def test_atexit(self):
-skip("Python3 atexit is a builtin module")
+py.test.skip("Python3 atexit is a builtin module")
 child = self.spawn([])
 child.expect('>>> ')
 child.sendline('def f(): print("foobye")')
@@ -525,9 +525,9 @@
 
 def test_options_i_m(self, monkeypatch):
 if sys.platform == "win32":
-skip("close_fds is not supported on Windows platforms")
+py.test.skip("close_fds is not supported on Windows platforms")
 if not hasattr(runpy, '_run_module_as_main'):
-skip("requires CPython >= 2.6")
+py.test.skip("requires CPython >= 2.6")
 p = os.path.join(os.path.realpath(os.path.dirname(__file__)), 
'mymodule.py')
 p = os.path.abspath(p)
 monkeypatch.chdir(os.path.dirname(app_main))
@@ -557,7 +557,7 @@
 
 def test_options_u_i(self):
 if sys.platform == "win32":
-skip("close_fds is not supported on Windows platforms")
+py.test.skip("close_fds is not supported on Windows platforms")
 import subprocess, select, os
 pipe = subprocess.Popen([get_python3(), app_main, "-u", "-i"],
 stdout=subprocess.PIPE,
@@ -614,7 +614,7 @@
 del os.environ['PYTHONINSPECT_']
 
 def test_stdout_flushes_before_stdin_blocks(self):
-skip("Python3 does not implement this behavior")
+py.test.skip("Python3 does not implement this behavior")
 # This doesn't really test app_main.py, but a behavior that
 # can only be checked on top of py.py with pexpect.
 path = getscript("""
@@ -632,7 +632,7 @@
 
 def test_no_space_before_argument(self, monkeypatch):
 if not hasattr(runpy, '_run_module_as_main'):
-skip("requires CPython >= 2.6")
+py.test.skip("requires CPython >= 2.6")
 child = self.spawn(['-cprint("hel" + "lo")'])
 child.expect('hello')
 
@@ -753,7 +753,7 @@
 
 def test_option_m(self, monkeypatch):
 if not hasattr(runpy, '_run_module_as_main'):
-skip("requires CPython >= 2.6")
+py.test.skip("requires CPython >= 2.6")
 p = os.path.join(os.path.realpath(os.path.dirname(__file__)), 
'mymodule.py')
 p = os.path.abspath(p)
 monkeypatch.chdir(os.path.dirname(app_main))
@@ -767,7 +767,7 @@
 
 def test_option_m_package(self, monkeypatch):
 if not hasattr(runpy, '_run_module_as_main'):
-skip("requires CPython >= 2.6")
+py.test.skip("requires CPython >= 2.6")
 p = os.path.join(os.path.realpath(os.path.dirname(__file__)),
  'mypackage', '__main__.py')
 p = os.path.abspath(p)
diff --git a/pypy/interpreter/unicodehelper.py 
b/pypy/interpreter/unicodehelper.py
--- a/pypy/interpreter/unicodehelper.py
+++ b/pypy/interpreter/unicodehelper.py
@@ -168,6 +168,222 @@
 return decode_utf8(space, string, allow_surrogates=True)
 
 # 
+# utf-16
+
+def str_decode_utf_16(s, size, errors, final=True,
+   errorhandler=None):
+result, length, byteorder = str_decode_utf_16_helper(s, size, errors, 
final,
+ errorhandler, 
"native",
+ 'utf-16-' + 
BYTEORDER2)
+return result, length
+
+def str_decode_utf_16_be(s, size, errors, final=True,
+  errorhandler=None):
+result, length, byteorder = str_decode_utf_16_helper(s, size, errors, 
final,
+ errorhandler, "big",

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

2018-05-14 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r94584:f2eac1569fb6
Date: 2018-05-14 22:49 +0200
http://bitbucket.org/pypy/pypy/changeset/f2eac1569fb6/

Log:merge py3.5

diff too long, truncating to 2000 out of 5543 lines

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/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/dotviewer/font/NOTICE b/dotviewer/font/COPYING.txt
rename from dotviewer/font/NOTICE
rename to dotviewer/font/COPYING.txt
diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py
--- a/lib-python/3/datetime.py
+++ b/lib-python/3/datetime.py
@@ -7,6 +7,9 @@
 import time as _time
 import math as _math
 
+# for cpyext, use these as base classes
+from __pypy__._pypydatetime import dateinterop, deltainterop, timeinterop
+
 def _cmp(x, y):
 return 0 if x == y else 1 if x > y else -1
 
@@ -332,8 +335,7 @@
 
 return q
 
-
-class timedelta:
+class timedelta(deltainterop):
 """Represent the difference between two datetime objects.
 
 Supported operators:
@@ -446,7 +448,7 @@
 if abs(d) > 9:
 raise OverflowError("timedelta # of days is too large: %d" % d)
 
-self = object.__new__(cls)
+self = deltainterop.__new__(cls)
 self._days = d
 self._seconds = s
 self._microseconds = us
@@ -655,7 +657,7 @@
   microseconds=99)
 timedelta.resolution = timedelta(microseconds=1)
 
-class date:
+class date(dateinterop):
 """Concrete date type.
 
 Constructors:
@@ -695,12 +697,12 @@
 if month is None and isinstance(year, bytes) and len(year) == 4 and \
 1 <= year[2] <= 12:
 # Pickle support
-self = object.__new__(cls)
+self = dateinterop.__new__(cls)
 self.__setstate(year)
 self._hashcode = -1
 return self
 year, month, day = _check_date_fields(year, month, day)
-self = object.__new__(cls)
+self = dateinterop.__new__(cls)
 self._year = year
 self._month = month
 self._day = day
@@ -1026,7 +1028,7 @@
 
 _tzinfo_class = tzinfo
 
-class time:
+class time(timeinterop):
 """Time with time zone.
 
 Constructors:
@@ -1063,14 +1065,14 @@
 """
 if isinstance(hour, bytes) and len(hour) == 6 and hour[0]&0x7F < 24:
 # Pickle support
-self = object.__new__(cls)
+self = timeinterop.__new__(cls)
 self.__setstate(hour, minute or None)
 self._hashcode = -1
 return self
 hour, minute, second, microsecond, fold = _check_time_fields(
 hour, minute, second, microsecond, fold)
 _check_tzinfo_arg(tzinfo)
-self = object.__new__(cls)
+self = timeinterop.__new__(cls)
 self._hour = hour
 self._minute = minute
 self._second = second
@@ -1376,7 +1378,7 @@
 microsecond=0, tzinfo=None, *, fold=0):
 if isinstance(year, bytes) and len(year) == 10 and 1 <= year[2]&0x7F 
<= 12:
 # Pickle support
-self = object.__new__(cls)
+self = dateinterop.__new__(cls)
 self.__setstate(year, month)
 self._hashcode = -1
 return self
@@ -1384,7 +1386,7 @@
 hour, minute, second, microsecond, fold = _check_time_fields(
 hour, minute, second, microsecond, fold)
 _check_tzinfo_arg(tzinfo)
-self = object.__new__(cls)
+self = dateinterop.__new__(cls)
 self._year = year
 self._month = month
 self._day = day
diff --git a/lib-python/3/distutils/sysconfig_pypy.py 
b/lib-python/3/distutils/sysconfig_pypy.py
--- a/lib-python/3/distutils/sysconfig_pypy.py
+++ b/lib-python/3/distutils/sysconfig_pypy.py
@@ -63,39 +63,9 @@
 
 def _init_posix():
 """Initialize the module as appropriate for POSIX systems."""
-so_ext = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
-
-g = {}
-g['CC'] = "cc -pthread"
-g['CXX'] = "c++ -pthread"
-g['OPT'] = "-DNDEBUG -O2"
-g['CFLAGS'] = "-DNDEBUG -O2"
-g['CCSHARED'] = "-fPIC"
-g['LDSHARED'] = "cc -pthread -shared"
-g['EXT_SUFFIX'] = so_ext
-g['SHLIB_SUFFIX'] = ".so"
-g['SO'] = so_ext  # deprecated in Python 3, 

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

2018-02-09 Thread mattip
Author: Matti Picus 
Branch: py3.6
Changeset: r93795:d9e0d13cf28e
Date: 2018-02-09 17:28 -0500
http://bitbucket.org/pypy/pypy/changeset/d9e0d13cf28e/

Log:merge py3.5

diff too long, truncating to 2000 out of 2839 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: 

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

2018-02-09 Thread cfbolz
Author: Carl Friedrich Bolz-Tereick 
Branch: py3.6
Changeset: r93789:9c18391110eb
Date: 2018-02-09 11:06 +0100
http://bitbucket.org/pypy/pypy/changeset/9c18391110eb/

Log:merge py3.5

diff too long, truncating to 2000 out of 17345 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -44,3 +44,10 @@
 d72f9800a42b46a8056951b1da2426d2c2d8d502 release-pypy3.5-v5.9.0
 03d614975835870da65ff0481e1edad68ebbcb8d release-pypy2.7-v5.9.0
 84a2f3e6a7f88f2fe698e473998755b3bd1a12e2 release-pypy2.7-v5.9.0
+0e7ea4fe15e82d5124e805e2e4a37cae1a402d4b release-pypy2.7-v5.10.0
+a91df6163fb76df245091f741dbf6a23ddc72374 release-pypy3.5-v5.10.0
+a91df6163fb76df245091f741dbf6a23ddc72374 release-pypy3.5-v5.10.0
+ release-pypy3.5-v5.10.0
+ release-pypy3.5-v5.10.0
+09f9160b643e3f02ccb8c843b2fbb4e5cbf54082 release-pypy3.5-v5.10.0
+3f6eaa010fce78cc7973bdc1dfdb95970f08fed2 release-pypy3.5-v5.10.1
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -30,7 +30,7 @@
 DEALINGS IN THE SOFTWARE.
 
 
-PyPy Copyright holders 2003-2017
+PyPy Copyright holders 2003-2018
 --- 
 
 Except when otherwise stated (look for LICENSE files or information at
@@ -339,8 +339,10 @@
   Stanisaw Halik
   Julien Phalip
   Roman Podoliaka
+  Steve Papanik
   Eli Stevens
   Boglarka Vezer
+  gabrielg
   PavloKapyshin
   Tomer Chachamu
   Christopher Groskopf
@@ -363,11 +365,13 @@
   Konrad Delong
   Dinu Gherman
   pizi
+  Tom Pruina
   James Robert
   Armin Ronacher
   Diana Popa
   Mads Kiilerich
   Brett Cannon
+  Caleb Hattingh
   aliceinwire
   Zooko Wilcox-O Hearn
   James Lan
@@ -388,6 +392,7 @@
   Jason Madden
   Yaroslav Fedevych
   Even Wiik Thomassen
+  m...@funkyhat.org
   Stefan Marr
 
   Heinrich-Heine University, Germany 
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_import.py b/extra_tests/test_import.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_import.py
@@ -0,0 +1,41 @@
+import pytest
+import sys
+import time
+from _thread import start_new_thread
+
+@pytest.mark.xfail('__pypy__' not in sys.builtin_module_names,
+   reason='Fails on CPython')
+def test_multithreaded_import(tmpdir):
+tmpfile = tmpdir.join('multithreaded_import_test.py')
+tmpfile.write('''if 1:
+x = 666
+import time
+for i in range(1000): time.sleep(0.001)
+x = 42
+''')
+
+oldpath = sys.path[:]
+try:
+sys.path.insert(0, str(tmpdir))
+got = []
+
+def check():
+import multithreaded_import_test
+got.append(getattr(multithreaded_import_test, 'x', '?'))
+
+for i in range(5):
+start_new_thread(check, ())
+
+for n in range(100):
+for i in range(105):
+time.sleep(0.001)
+if len(got) == 5:
+break
+else:
+raise AssertionError("got %r so far but still waiting" %
+(got,))
+
+assert got == [42] * 5
+
+finally:
+sys.path[:] = oldpath
diff --git a/extra_tests/test_json.py b/extra_tests/test_json.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_json.py
@@ -0,0 +1,29 @@
+import pytest
+import json
+from hypothesis import given, strategies
+
+def is_(x, y):
+return type(x) is type(y) and x == y
+
+def test_no_ensure_ascii():
+assert is_(json.dumps(u"\u1234", ensure_ascii=False), u'"\u1234"')
+assert is_(json.dumps(u"\xc0", ensure_ascii=False), u'"\xc0"')
+with pytest.raises(TypeError):
+json.dumps((u"\u1234", b"x"), ensure_ascii=False)
+with pytest.raises(TypeError):
+json.dumps((b"x", u"\u1234"), ensure_ascii=False)
+
+def test_issue2191():
+assert is_(json.dumps(u"xxx", ensure_ascii=False), u'"xxx"')
+
+jsondata = strategies.recursive(
+strategies.none() |
+strategies.booleans() |
+strategies.floats(allow_nan=False) |
+strategies.text(),
+lambda children: strategies.lists(children) |
+strategies.dictionaries(strategies.text(), children))
+
+@given(jsondata)
+def test_roundtrip(d):
+assert json.loads(json.dumps(d)) == d
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
+#