[pypy-commit] pypy redirect-assembler-jitlog: merge default

plan_rich pypy.commits at gmail.com
Fri Aug 19 08:47:51 EDT 2016


Author: Richard Plangger <planrichi at gmail.com>
Branch: redirect-assembler-jitlog
Changeset: r86313:5e73f119f5f7
Date: 2016-08-19 14:47 +0200
http://bitbucket.org/pypy/pypy/changeset/5e73f119f5f7/

Log:	merge default

diff --git a/lib_pypy/resource.py b/lib_pypy/resource.py
--- a/lib_pypy/resource.py
+++ b/lib_pypy/resource.py
@@ -86,7 +86,11 @@
     if len(limits) != 2:
         raise ValueError("expected a tuple of 2 integers")
 
-    if lib.my_setrlimit(resource, limits[0], limits[1]) == -1:
+    # accept and round down floats, like CPython does
+    limit0 = int(limits[0])
+    limit1 = int(limits[1])
+
+    if lib.my_setrlimit(resource, limit0, limit1) == -1:
         if ffi.errno == EINVAL:
             raise ValueError("current limit exceeds maximum limit")
         elif ffi.errno == EPERM:
diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -356,6 +356,11 @@
 that a C-level traceback is usually of no help at all in PyPy.
 Debugging PyPy can be annoying.
 
+`This is a clear and useful bug report.`__  (Admittedly, sometimes
+the problem is really hard to reproduce, but please try to.)
+
+.. __: https://bitbucket.org/pypy/pypy/issues/2363/segfault-in-gc-pinned-object-in
+
 In more details:
 
 * First, please give the exact PyPy version, and the OS.
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
@@ -387,7 +387,8 @@
     def _stacksize(self, blocks):
         """Compute co_stacksize."""
         for block in blocks:
-            block.initial_depth = 0
+            block.initial_depth = -99
+        blocks[0].initial_depth = 0
         # Assumes that it is sufficient to walk the blocks in 'post-order'.
         # This means we ignore all back-edges, but apart from that, we only
         # look into a block when all the previous blocks have been done.
@@ -406,8 +407,11 @@
 
     def _do_stack_depth_walk(self, block):
         depth = block.initial_depth
+        if depth == -99:     # this block is never reached, skip
+             return 0
         for instr in block.instructions:
             depth += _opcode_stack_effect(instr.opcode, instr.arg)
+            assert depth >= 0
             if depth >= self._max_depth:
                 self._max_depth = depth
             jump_op = instr.opcode
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -596,7 +596,10 @@
 
         # First extract the signature from the (CPython-level) code object
         from pypy.interpreter import pycode
-        argnames, varargname, kwargname = pycode.cpython_code_signature(func.func_code)
+        sig = pycode.cpython_code_signature(func.func_code)
+        argnames = sig.argnames
+        varargname = sig.varargname
+        kwargname = sig.kwargname
         self._argnames = argnames
 
         if unwrap_spec is None:
@@ -620,7 +623,9 @@
         app_sig = SignatureBuilder(func)
 
         UnwrapSpec_Check(orig_sig).apply_over(unwrap_spec, app_sig)
-        self.sig = argnames, varargname, kwargname = app_sig.signature()
+        self.sig = app_sig.signature()
+        argnames = self.sig.argnames
+        varargname = self.sig.varargname
 
         self.minargs = len(argnames)
         if varargname:
@@ -951,7 +956,7 @@
                 defs_w.append(space.wrap(defaultval))
         if self._code._unwrap_spec:
             UNDEFINED = object()
-            alldefs_w = [UNDEFINED] * len(self._code.sig[0])
+            alldefs_w = [UNDEFINED] * len(self._code.sig.argnames)
             if defs_w:
                 alldefs_w[-len(defs_w):] = defs_w
             code = self._code
@@ -968,7 +973,7 @@
                     assert isinstance(w_default, W_Root)
                     assert argname.startswith('w_')
                     argname = argname[2:]
-                    j = self._code.sig[0].index(argname)
+                    j = self._code.sig.argnames.index(argname)
                     assert alldefs_w[j] in (UNDEFINED, None)
                     alldefs_w[j] = w_default
             first_defined = 0
diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -37,7 +37,7 @@
 
 # cpython_code_signature helper
 def cpython_code_signature(code):
-    "([list-of-arg-names], vararg-name-or-None, kwarg-name-or-None)."
+    """Return a Signature instance."""
     argcount = code.co_argcount
     varnames = code.co_varnames
     assert argcount >= 0     # annotator hint
diff --git a/pypy/interpreter/signature.py b/pypy/interpreter/signature.py
--- a/pypy/interpreter/signature.py
+++ b/pypy/interpreter/signature.py
@@ -55,18 +55,3 @@
         if not isinstance(other, Signature):
             return NotImplemented
         return not self == other
-
-
-    # make it look tuply for its use in the annotator
-
-    def __len__(self):
-        return 3
-
-    def __getitem__(self, i):
-        if i == 0:
-            return self.argnames
-        if i == 1:
-            return self.varargname
-        if i == 2:
-            return self.kwargname
-        raise IndexError
\ No newline at end of file
diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -46,13 +46,6 @@
         assert sig.find_argname("c") == 2
         assert sig.find_argname("d") == -1
 
-    def test_tuply(self):
-        sig = Signature(["a", "b", "c"], "d", "e")
-        x, y, z = sig
-        assert x == ["a", "b", "c"]
-        assert y == "d"
-        assert z == "e"
-
 class dummy_wrapped_dict(dict):
     def __nonzero__(self):
         raise NotImplementedError
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -203,7 +203,8 @@
     name = func.__name__
     extra = ', '.join(extraargs)
     from pypy.interpreter import pycode
-    argnames, _, _ = pycode.cpython_code_signature(func.func_code)
+    sig = pycode.cpython_code_signature(func.func_code)
+    argnames = sig.argnames
     if use_closure:
         if argnames[1] == 'space':
             args = "closure, space, obj"
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
@@ -69,10 +69,13 @@
         sub_ffi.set_source('re_py_subsrc', None)
         sub_ffi.emit_python_code(str(tmpdir.join('re_py_subsrc.py')))
         #
-        space.appexec([space.wrap(str(tmpdir))], """(path):
-            import _cffi_backend     # force it to be initialized
-            import sys
-            sys.path.insert(0, path)
+        cls.w_fix_path = space.appexec([space.wrap(str(tmpdir))], """(path):
+            def fix_path(ignored=None):
+                import _cffi_backend     # force it to be initialized
+                import sys
+                if path not in sys.path:
+                    sys.path.insert(0, path)
+            return fix_path
         """)
 
     def teardown_method(self, meth):
@@ -86,17 +89,20 @@
 
 
     def test_constant_1(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         assert ffi.integer_const('FOOBAR') == -42
         assert ffi.integer_const('FOOBAZ') == -43
 
     def test_large_constant(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         assert ffi.integer_const('BIGPOS') == 420000000000
         assert ffi.integer_const('BIGNEG') == -420000000000
 
     def test_function(self):
         import _cffi_backend
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         assert lib.add42(-10) == 32
@@ -104,6 +110,7 @@
 
     def test_dlclose(self):
         import _cffi_backend
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         ffi.dlclose(lib)
@@ -115,17 +122,20 @@
             "library '%s' has been closed" % (self.extmod,))
 
     def test_constant_via_lib(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         assert lib.FOOBAR == -42
         assert lib.FOOBAZ == -43
 
     def test_opaque_struct(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         ffi.cast("struct foo_s *", 0)
         raises(TypeError, ffi.new, "struct foo_s *")
 
     def test_nonopaque_struct(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         for p in [ffi.new("struct bar_s *", [5, b"foobar"]),
                   ffi.new("bar_t *", [5, b"foobar"])]:
@@ -134,12 +144,14 @@
             assert p.a[5] == ord('r')
 
     def test_enum(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         assert ffi.integer_const("BB") == 1
         e = ffi.cast("enum foo_e", 2)
         assert ffi.string(e) == "CC"
 
     def test_include_1(self):
+        self.fix_path()
         from re_py_subsrc import ffi
         assert ffi.integer_const('FOOBAR') == -42
         assert ffi.integer_const('FOOBAZ') == -43
@@ -153,6 +165,7 @@
         assert p.a[4] == ord('a')
 
     def test_global_var(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         assert lib.globalvar42 == 1234
@@ -163,24 +176,28 @@
         assert lib.globalvar42 == 1238
 
     def test_global_const_int(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         assert lib.globalconst42 == 4321
         raises(AttributeError, ffi.addressof, lib, 'globalconst42')
 
     def test_global_const_nonint(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         assert ffi.string(lib.globalconsthello, 8) == "hello"
         raises(AttributeError, ffi.addressof, lib, 'globalconsthello')
 
     def test_rtld_constants(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         ffi.RTLD_NOW    # check that we have the attributes
         ffi.RTLD_LAZY
         ffi.RTLD_GLOBAL
 
     def test_no_such_function_or_global_var(self):
+        self.fix_path()
         from re_python_pysrc import ffi
         lib = ffi.dlopen(self.extmod)
         e = raises(ffi.error, getattr, lib, 'no_such_function')
diff --git a/pypy/module/_jitlog/test/test__jitlog.py b/pypy/module/_jitlog/test/test__jitlog.py
--- a/pypy/module/_jitlog/test/test__jitlog.py
+++ b/pypy/module/_jitlog/test/test__jitlog.py
@@ -10,10 +10,10 @@
 
     def setup_class(cls):
         cls.w_tmpfilename = cls.space.wrap(str(udir.join('test__jitlog.1')))
-        cls.w_mark_header = cls.space.wrap(jl.MARK_JITLOG_HEADER)
-        cls.w_version = cls.space.wrap(jl.JITLOG_VERSION_16BIT_LE)
+        cls.w_mark_header = cls.space.newbytes(jl.MARK_JITLOG_HEADER)
+        cls.w_version = cls.space.newbytes(jl.JITLOG_VERSION_16BIT_LE)
         cls.w_is_32bit = cls.space.wrap(sys.maxint == 2**31-1)
-        cls.w_machine = cls.space.wrap(platform.machine())
+        cls.w_machine = cls.space.newbytes(platform.machine())
         cls.w_resops = cls.space.newdict()
         space = cls.space
         for key, value in opname.items():
@@ -48,5 +48,3 @@
                 assert opnum in self.resops
                 # the name must equal
                 assert self.resops[opnum] == opname
-
-
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
@@ -11,7 +11,7 @@
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rlib.objectmodel import we_are_translated, keepalive_until_here
 from rpython.rlib.objectmodel import dont_inline
-from rpython.rlib.rfile import (FILEP, c_fread, c_fclose, c_fwrite, 
+from rpython.rlib.rfile import (FILEP, c_fread, c_fclose, c_fwrite,
         c_fdopen, c_fileno,
         c_fopen)# for tests
 from rpython.translator import cdir
@@ -259,14 +259,14 @@
 
         # extract the signature from the (CPython-level) code object
         from pypy.interpreter import pycode
-        argnames, varargname, kwargname = pycode.cpython_code_signature(callable.func_code)
+        sig = pycode.cpython_code_signature(callable.func_code)
+        assert sig.argnames[0] == 'space'
+        self.argnames = sig.argnames[1:]
+        if gil == 'pygilstate_ensure':
+            assert self.argnames[-1] == 'previous_state'
+            del self.argnames[-1]
+        assert len(self.argnames) == len(self.argtypes)
 
-        assert argnames[0] == 'space'
-        if gil == 'pygilstate_ensure':
-            assert argnames[-1] == 'previous_state'
-            del argnames[-1]
-        self.argnames = argnames[1:]
-        assert len(self.argnames) == len(self.argtypes)
         self.gil = gil
         self.result_borrowed = result_borrowed
         self.result_is_ll = result_is_ll
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
@@ -619,6 +619,7 @@
             assert os.geteuid() == self.geteuid
 
     if hasattr(os, 'setuid'):
+        @py.test.mark.skipif("sys.version_info < (2, 7, 4)")
         def test_os_setuid_error(self):
             os = self.posix
             raises(OverflowError, os.setuid, -2)
@@ -666,6 +667,7 @@
             raises(OSError, os.getpgid, 1234567)
 
     if hasattr(os, 'setgid'):
+        @py.test.mark.skipif("sys.version_info < (2, 7, 4)")
         def test_os_setgid_error(self):
             os = self.posix
             raises(OverflowError, os.setgid, -2)
diff --git a/pypy/module/test_lib_pypy/test_resource.py b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -45,5 +45,8 @@
 
 def test_setrlimit():
     # minimal "does not crash" test
-    x = resource.getrlimit(resource.RLIMIT_CPU)
-    resource.setrlimit(resource.RLIMIT_CPU, x)
+    x, y = resource.getrlimit(resource.RLIMIT_CPU)
+    resource.setrlimit(resource.RLIMIT_CPU, (x, y))
+    x += 0.2
+    y += 0.3
+    resource.setrlimit(resource.RLIMIT_CPU, (x, y))    # truncated to ints
diff --git a/pypy/tool/pytest/genreportdata.py b/pypy/tool/pytest/genreportdata.py
--- a/pypy/tool/pytest/genreportdata.py
+++ b/pypy/tool/pytest/genreportdata.py
@@ -17,7 +17,7 @@
             resultwc = py.path.svnwc(testresultdir)
             print "updating", resultwc
             resultwc.update()
-        except KeyboardInterrupt as RuntimeError:
+        except (KeyboardInterrupt, RuntimeError):
             raise
         except Exception as e: #py.process.ExecutionFailed,e:
             print >> sys.stderr, "Warning: ",e #Subversion update failed"


More information about the pypy-commit mailing list