[IPython-dev] weird bug -- any ideas

Fernando Perez Fernando.Perez@berkeley....
Mon Nov 16 05:28:54 CST 2009

On Mon, Nov 16, 2009 at 2:31 AM, Fernando Perez
<Fernando.Perez@berkeley.edu> wrote:
> The fact that Ctrl-C cleanly stops the crazy loop *without* a
> KeyboardInterrupt makes me think that ipython is trying to introspect
> the MS object and some C code is going into a mad loop (otherwise we'd
> see the Python signal handler showing a traceback).  Do you have any
> other bugs related to this type of object that sound along those
> lines?

Half-right. IPython is swallowing the kbd interrupt, but the bug is in
sage, it's the fact that len(MS) never returns:

sage: MS = MatrixSpace(QQ,6,6,sparse=True); MS
Full MatrixSpace of 6 by 6 sparse matrices over Rational Field
sage: len(MS)
KeyboardInterrupt                         Traceback (most recent call last)

/home/fperez/ipython/repo/kernel-config-lp/docs/<ipython console> in <module>()

in sage.structure.parent.Parent.__len__

in sage.structure.parent.Parent.list (sage/structure/parent.c:4995)()

in __iter__(self)
    751             while True:
    752                 for iv in
--> 753                     yield self(entries=[base_elements[i] for i
in iv], rows=True)
    755                 weight += 1

in __call__(self, entries, coerce, copy, rows)
    371             copy = False
    372         elif self.__is_sparse and isinstance(entries, (list, tuple)):
--> 373             entries = list_to_dict(entries, self.__nrows,
self.__ncols, rows=rows)
    374             coerce = True
    375             copy = False

in list_to_dict(entries, nrows, ncols, rows)
   1240                 d[(row,col)] = x
   1241             else:
-> 1242                 d[(col,row)] = x
   1243     return d

in my_sigint(x, n)
      8 def my_sigint(x, n):
----> 9     raise KeyboardInterrupt
     11 def my_sigfpe(x, n):


It seems that the ms object implements __len__, but this function
never returns.  It's just that ipython was calling len() on it.



More information about the IPython-dev mailing list