Message3182
And here is a change to the PyDerivedDict#__cmp___ that make us pass the
TestSuite.
public int __cmp__(PyObject other) {
PyType self_type=getType();
PyType[] where_type = new PyType[1];
PyObject impl = self_type.lookup_where("__cmp__", where_type);
// Full Compatibility with CPython __cmp__:
// If the derived type don't override __cmp__, the
// *internal* PyDictionary#__cmp__ should be called, not the
exposed
// one. The difference is that the exposed dict.__cmp__ throws a
// TypeError if the argument is an instance of dict.
//
// BTW, impl should never be null, because, if __cmp__ has not been
// overidden, it should be the *exposed*
PyDictionary#dict___cmp__.
// But checking for that won't hurt.
if (impl == null || where_type[0] == PyDictionary.TYPE) {
return super.__cmp__(other);
}
PyObject res=impl.__get__(this,self_type).__call__(other);
if (res instanceof PyInteger) {
int v=((PyInteger)res).getValue();
return v<0?-1:v>0?1:0;
}
throw Py.TypeError("__cmp__ should return a int");
}
That was before I was told that the method was generated by gderived.py.
Now I don't know if I should adapt the object.derived template to
generate similar code, or not. Thoughts? |
|
Date |
User |
Action |
Args |
2008-05-03 02:42:36 | leosoto | set | spambayes_score: 0.00829033 -> 0.008290332 messageid: <1209782556.43.0.910374762091.issue1031@psf.upfronthosting.co.za> |
2008-05-03 02:42:36 | leosoto | set | spambayes_score: 0.00829033 -> 0.00829033 recipients:
+ leosoto, fwierzbicki |
2008-05-03 02:42:36 | leosoto | link | issue1031 messages |
2008-05-03 02:42:35 | leosoto | create | |
|