Author: Richard Plangger <planri...@gmail.com>
Branch: py3.5-async-translate
Changeset: r86103:3db60dde36a5
Date: 2016-08-09 14:13 +0200
http://bitbucket.org/pypy/pypy/changeset/3db60dde36a5/

Log:    merged py3.5 changes

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -18,7 +18,6 @@
 from pypy.interpreter.nestedscope import Cell
 from pypy.interpreter.pycode import PyCode, BytecodeCorruption
 from pypy.tool.stdlib_opcode import bytecode_spec
-from pypy.objspace.std.dictmultiobject import W_DictMultiObject
 
 CANNOT_CATCH_MSG = ("catching classes that don't inherit from BaseException "
                     "is not allowed in 3.x")
@@ -1391,9 +1390,8 @@
         self.pushvalue(w_sum)
 
     def BUILD_TUPLE_UNPACK(self, itemcount, next_instr):
-        space = self.space
         w_sum_list = list_unpack_helper(self, itemcount)
-        self.pushvalue(space.newtuple(w_sum_list))
+        self.pushvalue(self.space.newtuple(w_sum_list))
 
     def BUILD_LIST_UNPACK(self, itemcount, next_instr):
         w_sum = list_unpack_helper(self, itemcount)
diff --git a/pypy/interpreter/test/test_interpreter.py 
b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -256,7 +256,63 @@
             return a, b, c, d
         """
         assert self.codetest(code, "f", [1, 2], {"d" : 4, "c" : 3}) == (1, 2, 
3, 4)
-
+    
+    def test_build_set_unpack(self):
+        code = """ def f():
+            return {*range(4), 4, *(5, 6, 7)}
+        """
+        space = self.space
+        res = self.codetest(code, "f", [])
+        l_res = space.call_function(space.w_list, res)
+        assert space.unwrap(l_res) == [0, 1, 2, 3, 4, 5, 6, 7]
+        
+    def test_build_tuple_unpack(self):
+        code = """ def f():
+            return (*range(4), 4)
+        """
+        assert self.codetest(code, "f", []) == (0, 1, 2, 3, 4)
+    
+    def test_build_list_unpack(self):
+        code = """ def f():
+            return [*range(4), 4]
+        """
+        assert self.codetest(code, "f", []) == [0, 1, 2, 3, 4]
+    
+    def test_build_map_unpack(self):
+        code = """
+        def f():
+            return {'x': 1, **{'y': 2}}
+        def g():
+            return {**()}
+        """
+        assert self.codetest(code, "f", []) == {'x': 1, 'y': 2}
+        res = self.codetest(code, 'g', [])
+        assert "TypeError:" in res
+        assert "'tuple' object is not a mapping" in res
+    
+    def test_build_map_unpack_with_call(self):
+        code = """
+        def f(a,b,c,d):
+            return a+b,c+d
+        def g1():
+            return f(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4})
+        def g2():
+            return f(**{'a': 1, 'c': 3}, **[])
+        def g3():
+            return f(**{'a': 1, 'c': 3}, **{1: 3})
+        def g4():
+            return f(**{'a': 1, 'c': 3}, **{'a': 2})
+        """
+        assert self.codetest(code, "g1", []) == (3, 7)
+        resg2 = self.codetest(code, 'g2', [])
+        assert "TypeError:" in resg2
+        assert "'list' object is not a mapping" in resg2
+        resg3 = self.codetest(code, 'g3', [])
+        assert "TypeError:" in resg3
+        assert "keywords must be strings" in resg3
+        resg4 = self.codetest(code, 'g4', [])
+        assert "TypeError:" in resg4
+        assert "f() got multiple values for keyword argument 'a'" in resg4
 
 
 class AppTestInterpreter: 
diff --git a/pypy/module/_asyncio/test/test_asyncio.py 
b/pypy/module/_asyncio/test/test_asyncio.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/_asyncio/test/test_asyncio.py
@@ -0,0 +1,14 @@
+class AppTestAsyncIO(object):
+    
+    spaceconfig = 
dict(usemodules=["select","_socket","thread","signal","struct","_multiprocessing","array","_posixsubprocess","fcntl","unicodedata"])
+    
+    def test_gil_issue(self):
+        # the problem occured at await asyncio.open_connection after calling 
run_until_complete
+        """
+        import encodings.idna
+        import asyncio
+        async def f():
+            reader, writer = await asyncio.open_connection('example.com', 80)
+        
+        loop = asyncio.get_event_loop()
+        loop.run_until_complete(f())"""
diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -147,7 +147,8 @@
 def set_sentinel(space):
     """Set a sentinel lock that will be released when the current thread
 state is finalized (after it is untied from the interpreter)."""
-    return space.wrap(Lock(space))
+    lock = allocate_lock(space)
+    return lock
 
 class W_RLock(W_Root):
     def __init__(self, space):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to