Author: Armin Rigo <ar...@tunes.org> Branch: py3k Changeset: r86293:b34a037a6866 Date: 2016-08-18 22:12 +0200 http://bitbucket.org/pypy/pypy/changeset/b34a037a6866/
Log: hg merge default 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 @@ -389,7 +389,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. @@ -408,8 +409,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 @@ -612,7 +612,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: @@ -636,7 +639,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: @@ -972,7 +977,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 @@ -993,7 +998,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 @@ -45,7 +45,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 if we_are_translated(): diff --git a/pypy/interpreter/signature.py b/pypy/interpreter/signature.py --- a/pypy/interpreter/signature.py +++ b/pypy/interpreter/signature.py @@ -68,18 +68,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 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 @@ -47,13 +47,6 @@ assert sig.find_argname("d") == -1 assert sig.find_argname("kwonly") == 3 - 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 @@ -202,7 +202,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/_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/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" _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit