Skip to content

Commit 96ec81b

Browse files
committed
Throw OverflowError if __len__ returns a value that is too large
Fixes http://bugs.jython.org/issue1929
1 parent 413b270 commit 96ec81b

147 files changed

Lines changed: 147 additions & 441 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/org/python/antlr/ast/AssertDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/AssignDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/AttributeDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/AugAssignDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/BinOpDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/BoolOpDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/BreakDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/CallDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/ClassDefDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

src/org/python/antlr/ast/CompareDerived.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ public int __len__() {
857857
PyObject impl=self_type.lookup("__len__");
858858
if (impl!=null) {
859859
PyObject res=impl.__get__(this,self_type).__call__();
860-
if (res instanceof PyInteger)
861-
return((PyInteger)res).getValue();
862-
throw Py.TypeError("__len__ should return a int");
860+
return res.asInt();
863861
}
864862
return super.__len__();
865863
}

0 commit comments

Comments
 (0)