From: <fwi...@us...> - 2008-06-06 18:12:46
|
Revision: 4547 http://jython.svn.sourceforge.net/jython/?rev=4547&view=rev Author: fwierzbicki Date: 2008-06-06 11:12:44 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Merged revisions 4544,4546 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r4544 | pjenvey | 2008-06-06 00:05:30 -0400 (Fri, 06 Jun 2008) | 3 lines raise a TypeError on invalid args to float fixes #1037 patch from lsoto ........ r4546 | fwierzbicki | 2008-06-06 13:36:22 -0400 (Fri, 06 Jun 2008) | 2 lines Fix and test for issue 1048 (List Comprehension in finally throws NPE). ........ Modified Paths: -------------- branches/asm/Lib/test/test_float_jy.py branches/asm/Lib/test/test_jy_compile.py branches/asm/NEWS branches/asm/src/org/python/compiler/CodeCompiler.java branches/asm/src/org/python/compiler/ScopeInfo.java branches/asm/src/org/python/compiler/ScopesCompiler.java branches/asm/src/org/python/core/PyFloat.java Property Changed: ---------------- branches/asm/ Property changes on: branches/asm ___________________________________________________________________ Name: svnmerge-integrated - /trunk/jython:1-4542 + /trunk/jython:1-4546 Modified: branches/asm/Lib/test/test_float_jy.py =================================================================== --- branches/asm/Lib/test/test_float_jy.py 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/Lib/test/test_float_jy.py 2008-06-06 18:12:44 UTC (rev 4547) @@ -80,7 +80,10 @@ #self.assert_(type(float('inf')), float) self.assertRaises(OverflowError, long, float('Infinity')) + def test_float_none(self): + self.assertRaises(TypeError, float, None) + def test_main(): test_support.run_unittest(FloatTestCase) Modified: branches/asm/Lib/test/test_jy_compile.py =================================================================== --- branches/asm/Lib/test/test_jy_compile.py 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/Lib/test/test_jy_compile.py 2008-06-06 18:12:44 UTC (rev 4547) @@ -89,6 +89,9 @@ av("\n \na**3","eval",value=8) av("#a\n#b\na**3","eval",value=8) + # this failed under 2.2.1 + av("def f():\n try: pass\n finally: [x for x in (1,2)]") + def test_incomplete(self): ai = self.assertIncomplete Modified: branches/asm/NEWS =================================================================== --- branches/asm/NEWS 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/NEWS 2008-06-06 18:12:44 UTC (rev 4547) @@ -16,7 +16,10 @@ - threading.local Jython 2.2.2 rc1 - Bugs fixed + Bugs fixed (new numbering due to move to Roundup) + - [ 1048 ] List Comprehension in finally throws NPE + + Bugs fixed (old sourceforge numbering) - [ 1806980 ] os.path.join ignores empty string - [ 1744567 ] Simultaneous read & write on socket FileWrapper causes hang - [ 1831710 ] PyFileCloser throws NullPointerException on shutdown Modified: branches/asm/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/asm/src/org/python/compiler/CodeCompiler.java 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/src/org/python/compiler/CodeCompiler.java 2008-06-06 18:12:44 UTC (rev 4547) @@ -1650,8 +1650,6 @@ return null; } - int list_comprehension_count = 0; - public int PyList_init2; public Object visitListComp(ListComp node) throws Exception { code.new_("org/python/core/PyList"); @@ -1665,7 +1663,8 @@ code.invokevirtual("org/python/core/PyObject", "__getattr__", "(" + $str + ")" + $pyObj); - String tmp_append = "_[" + (++list_comprehension_count) + "]"; + String tmp_append ="_[" + node.getLine() + "_" + node.getCharPositionInLine() + "]"; + System.out.println(tmp_append); set(new Name(node, tmp_append, expr_contextType.Store)); Modified: branches/asm/src/org/python/compiler/ScopeInfo.java =================================================================== --- branches/asm/src/org/python/compiler/ScopeInfo.java 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/src/org/python/compiler/ScopeInfo.java 2008-06-06 18:12:44 UTC (rev 4547) @@ -11,7 +11,6 @@ public String scope_name; public int level; public int func_level; - public int list_comprehension_count; public void dump() { // for debugging if (org.python.core.Options.verbose < org.python.core.Py.DEBUG) Modified: branches/asm/src/org/python/compiler/ScopesCompiler.java =================================================================== --- branches/asm/src/org/python/compiler/ScopesCompiler.java 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/src/org/python/compiler/ScopesCompiler.java 2008-06-06 18:12:44 UTC (rev 4547) @@ -236,7 +236,8 @@ } public Object visitListComp(ListComp node) throws Exception { - String tmp = "_[" + (++cur.list_comprehension_count) + "]"; + String tmp ="_[" + node.getLine() + "_" + node.getCharPositionInLine() + "]"; + System.out.println(tmp); cur.addBound(tmp); traverse(node); return null; Modified: branches/asm/src/org/python/core/PyFloat.java =================================================================== --- branches/asm/src/org/python/core/PyFloat.java 2008-06-06 17:36:22 UTC (rev 4546) +++ branches/asm/src/org/python/core/PyFloat.java 2008-06-06 18:12:44 UTC (rev 4547) @@ -24,16 +24,32 @@ PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("float", args, keywords, new String[] { "x" }, 0); PyObject x = ap.getPyObject(0, null); - if (new_.for_type == subtype) { - if (x == null) { + if (x == null) { + if (new_.for_type == subtype) { return new PyFloat(0.0); + } else { + return new PyFloatDerived(subtype, 0.0); } - return x.__float__(); } else { - if (x == null) { - return new PyFloatDerived(subtype, 0.0); + PyFloat floatObject = null; + try { + floatObject = x.__float__(); + } catch (PyException e) { + if (Py.matchException(e, Py.AttributeError)) { + // Translate AttributeError to TypeError + // XXX: We are using the same message as CPython, even if + // it is not strictly correct (instances of types + // that implement the __float__ method are also + // valid arguments) + throw Py.TypeError("float() argument must be a string or a number"); + } + throw e; } - return new PyFloatDerived(subtype, x.__float__().getValue()); + if (new_.for_type == subtype) { + return floatObject; + } else { + return new PyFloatDerived(subtype, floatObject.getValue()); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |