From: <fwi...@us...> - 2008-12-15 17:01:55
|
Revision: 5766 http://jython.svn.sourceforge.net/jython/?rev=5766&view=rev Author: fwierzbicki Date: 2008-12-15 17:01:52 +0000 (Mon, 15 Dec 2008) Log Message: ----------- Fix for http://bugs.jython.org/issue1758318. subclasses of __nonzero__ must return *exactly* PyInteger or PyBoolean. Just checking in template for now will check in the results of the template next. Modified Paths: -------------- trunk/jython/src/templates/object.derived Modified: trunk/jython/src/templates/object.derived =================================================================== --- trunk/jython/src/templates/object.derived 2008-12-15 14:12:18 UTC (rev 5765) +++ trunk/jython/src/templates/object.derived 2008-12-15 17:01:52 UTC (rev 5766) @@ -125,7 +125,13 @@ if (impl == null) return super.__nonzero__(); } - return impl.__get__(this,self_type).__call__().__nonzero__(); + PyObject o = impl.__get__(this,self_type).__call__(); + Class c = o.getClass(); + if (c != PyInteger.class && c != PyBoolean.class) { + throw Py.TypeError(String.format("__nonzero__ should return bool or int, returned %s", + self_type.getName())); + } + return o.__nonzero__(); } public boolean __contains__(PyObject o) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |