2011/1/4 Paul Ivanov <pivanov...@gmail.com>
> Hi matplotlib developers,
>
> I was answering a question on the -users list and came across a
> gridspec __getitem__ bug which causes an infinite loop if the
> user tries to iterate over it, because getitem never did a
> sanity-check when given an integer key.
>
> from matplotlib import gridspec
> gs = gridspec.GridSpec(1,2)
> gs[100] # no error is given, a SubplotSpec is returned
> [x for x in gs] # causes infinite loop before applying patch
>
> # after applying the patch - which is just lines 171-172 in the
> # traceback below
> In [9]: gs[100]
> ----------------------------------------------------------
> IndexError Traceback (most recent call last)
>
> ./matplotlib/<ipython console> in <module>()
>
> ./matplotlib/gridspec.pyc
> in __getitem__(self, key)
> 170 key += total
> 171 if key >= total or key < 0:
> --> 172 raise IndexError("index out of range")
> 173 num1, num2 = key, None
> 174
>
> IndexError: index out of range
>
>
Does this patch prevent the use of negative indexes? If so, then we might
want to rethink that in order to be more consistent with numpy arrays and
python lists...
Ben Root
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel