From: <zy...@us...> - 2009-02-14 13:22:20
|
Revision: 6029 http://jython.svn.sourceforge.net/jython/?rev=6029&view=rev Author: zyasoft Date: 2009-02-14 11:58:48 +0000 (Sat, 14 Feb 2009) Log Message: ----------- Fixed WITH_CLEANUP so that it properly calls __exit__ with the exception components off the stack. Modified Paths: -------------- branches/pbcvm/src/org/python/core/PyBytecode.java Modified: branches/pbcvm/src/org/python/core/PyBytecode.java =================================================================== --- branches/pbcvm/src/org/python/core/PyBytecode.java 2009-02-14 11:17:17 UTC (rev 6028) +++ branches/pbcvm/src/org/python/core/PyBytecode.java 2009-02-14 11:58:48 UTC (rev 6029) @@ -686,7 +686,7 @@ PyObject locals = stack.pop(); PyObject globals = stack.pop(); PyObject code = stack.pop(); - Py.exec(code, globals==Py.None ? null : globals, locals==Py.None ? null : locals); + Py.exec(code, globals == Py.None ? null : globals, locals == Py.None ? null : locals); break; } @@ -1048,12 +1048,19 @@ v = stack.top(3); w = stack.top(4); } - PyObject x = exit.__call__(u, v, w); - if (u != Py.None && x.__nonzero__()) { - stack.popN(4); + PyObject x = null; + if (u instanceof PyStackException) { + PyException exc = ((PyStackException) u).exception; + x = exit.__call__(exc.type, exc.value, exc.traceback); + } else { + x = exit.__call__(u, v, w); + } + + if (u != Py.None && x != null && x.__nonzero__()) { + stack.popN(4); // XXX - consider stack.stackadj op stack.push(Py.None); } else { - stack.pop(); + stack.pop(); // this should be popping off a block } break; } @@ -1087,8 +1094,8 @@ PyCode code = (PyCode) stack.pop(); PyObject[] defaults = stack.popN(oparg); PyObject doc = null; - if (code instanceof PyBytecode && ((PyBytecode)code).co_consts.length > 0) { - doc = ((PyBytecode)code).co_consts[0]; + if (code instanceof PyBytecode && ((PyBytecode) code).co_consts.length > 0) { + doc = ((PyBytecode) code).co_consts[0]; } PyFunction func = new PyFunction(f.f_globals, defaults, code, doc); stack.push(func); @@ -1100,8 +1107,8 @@ PyObject[] closure_cells = ((PySequenceList) (stack.pop())).getArray(); PyObject[] defaults = stack.popN(oparg); PyObject doc = null; - if (code instanceof PyBytecode && ((PyBytecode)code).co_consts.length > 0) { - doc = ((PyBytecode)code).co_consts[0]; + if (code instanceof PyBytecode && ((PyBytecode) code).co_consts.length > 0) { + doc = ((PyBytecode) code).co_consts[0]; } PyFunction func = new PyFunction(f.f_globals, defaults, code, doc, closure_cells); stack.push(func); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |