From: <pj...@us...> - 2008-06-24 00:46:00
|
Revision: 4734 http://jython.svn.sourceforge.net/jython/?rev=4734&view=rev Author: pjenvey Date: 2008-06-23 17:45:53 -0700 (Mon, 23 Jun 2008) Log Message: ----------- o 2.5 EnvironmentError needs a custom __reduce__ o disable failing testInfiniteRecursion Modified Paths: -------------- branches/asm/Lib/test/test_exceptions.py branches/asm/src/org/python/core/exceptions.java Modified: branches/asm/Lib/test/test_exceptions.py =================================================================== --- branches/asm/Lib/test/test_exceptions.py 2008-06-24 00:31:42 UTC (rev 4733) +++ branches/asm/Lib/test/test_exceptions.py 2008-06-24 00:45:53 UTC (rev 4734) @@ -339,6 +339,10 @@ def test_main(): + import test_support + if test_support.is_jython: + # XXX: http://bugs.jython.org/issue1063 + del ExceptionTests.testInfiniteRecursion run_unittest(ExceptionTests) if __name__ == '__main__': Modified: branches/asm/src/org/python/core/exceptions.java =================================================================== --- branches/asm/src/org/python/core/exceptions.java 2008-06-24 00:31:42 UTC (rev 4733) +++ branches/asm/src/org/python/core/exceptions.java 2008-06-24 00:45:53 UTC (rev 4734) @@ -243,6 +243,7 @@ defineSlots(dict, "errno", "strerror", "filename"); dict.__setitem__("__init__", bindStaticJavaMethod("__init__", "EnvironmentError__init__")); dict.__setitem__("__str__", bindStaticJavaMethod("__str__", "EnvironmentError__str__")); + dict.__setitem__("__reduce__", bindStaticJavaMethod("__reduce__", "EnvironmentError__reduce__")); return dict; } @@ -279,6 +280,27 @@ return Py.newString(result); } + public static PyObject EnvironmentError__reduce__(PyObject self, PyObject[] args, + String[] kwargs) { + PyBaseException selfBase = (PyBaseException)self; + PyObject reduceArgs = selfBase.args; + PyObject filename = self.__findattr__("filename"); + + // self->args is only the first two real arguments if there was a file name given + // to EnvironmentError + if (selfBase.args.__len__() == 2 && filename != null) { + reduceArgs = new PyTuple(selfBase.args.__finditem__(0), + selfBase.args.__finditem__(1), + filename); + } + + if (selfBase.__dict__ != null) { + return new PyTuple(selfBase.getType(), reduceArgs, selfBase.__dict__); + } else { + return new PyTuple(selfBase.getType(), reduceArgs); + } + } + public static PyObject SystemExit() { PyObject dict = new PyStringMap(); defineSlots(dict, "code"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |