From: <pj...@us...> - 2008-06-22 21:15:18
|
Revision: 4713 http://jython.svn.sourceforge.net/jython/?rev=4713&view=rev Author: pjenvey Date: 2008-06-22 14:15:16 -0700 (Sun, 22 Jun 2008) Log Message: ----------- throw a TypeError when __long__ isn't supported fixes #1059 Modified Paths: -------------- trunk/jython/src/org/python/core/PyLong.java Modified: trunk/jython/src/org/python/core/PyLong.java =================================================================== --- trunk/jython/src/org/python/core/PyLong.java 2008-06-21 23:42:05 UTC (rev 4712) +++ trunk/jython/src/org/python/core/PyLong.java 2008-06-22 21:15:16 UTC (rev 4713) @@ -41,7 +41,15 @@ return new PyLong(0); } if (base == -909) { - return x.__long__(); + try { + return x.__long__(); + } catch (PyException pye) { + if (!Py.matchException(pye, Py.AttributeError)) { + throw pye; + } + throw Py.TypeError(String.format("long() argument must be a string or a number, " + + "not '%.200s'", x.getType().fastGetName())); + } } if (!(x instanceof PyString)) { throw Py.TypeError("long: can't convert non-string with explicit base"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |