Changes between Initial Version and Version 1 of Ticket #22561
- Timestamp:
- Mar 10, 2017, 10:55:30 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #22561
-
Property
Component
changed from
number fields
tointerfaces
-
Property
Authors
changed from
to
Jeroen Demeyer
-
Property
Component
changed from
-
Ticket #22561 – Description
initial v1 1 1 The following reasonable and apparently innocuous code sends Sage into an infinite loop: 2 2 3 {{{ 3 4 sage: p = pari('x^2 + x + 1') 4 5 sage: list(p) 6 }}} 5 7 6 8 The reason is that the gen object has no {{{__iter__}}} method, but it has a {{{__getitem__}}} method which accepts any integer index and returns 0 for indices larger than the degree of the polynomial. Since there is no {{{__iter__}}} method, python builds an iterator using {{{__getitem__}}}. 7 8 There is a simple fix: {{{__getitem__}}} should raise an {{{IndexError}}} when the index is larger than the degree. I also think it should raise an {{{IndexError}}} when the index is negative.