Skip to content

Commit 34637ae

Browse files
committed
Derived changes for r5529 __cmp__ results
1 parent e71223d commit 34637ae

31 files changed

+124
-124
lines changed

src/org/python/core/PyArrayDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyBaseExceptionDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,11 @@ public int __cmp__(PyObject other) {
752752
return super.__cmp__(other);
753753
}
754754
PyObject res=impl.__get__(this,self_type).__call__(other);
755-
if (res instanceof PyInteger) {
756-
int v=((PyInteger)res).getValue();
757-
return v<0?-1:v>0?1:0;
755+
if (res==Py.NotImplemented) {
756+
return-2;
758757
}
759-
throw Py.TypeError("__cmp__ should return a int");
758+
int c=res.asInt();
759+
return c<0?-1:c>0?1:0;
760760
}
761761

762762
public boolean __nonzero__() {

src/org/python/core/PyBooleanDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyClassMethodDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyComplexDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyDictionaryDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyEnumerateDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyFileDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyFloatDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

src/org/python/core/PyFrozenSetDerived.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,11 @@ public int __cmp__(PyObject other) {
776776
return super.__cmp__(other);
777777
}
778778
PyObject res=impl.__get__(this,self_type).__call__(other);
779-
if (res instanceof PyInteger) {
780-
int v=((PyInteger)res).getValue();
781-
return v<0?-1:v>0?1:0;
779+
if (res==Py.NotImplemented) {
780+
return-2;
782781
}
783-
throw Py.TypeError("__cmp__ should return a int");
782+
int c=res.asInt();
783+
return c<0?-1:c>0?1:0;
784784
}
785785

786786
public boolean __nonzero__() {

0 commit comments

Comments
 (0)