On Thursday, August 3, 2017 at 7:58:50 PM UTC+2, Travis Scrimshaw wrote: > > Hey all, > I think I have come across a possible Cython bug, but I am not sure. I > am using 8.1beta0. Here is as small of a working example as I can currently > get. > > sage: %%cython > ....: def foo(F, int i): > ....: return F[i] > ....: def foo2(F, int i): > ....: return F._dictionary[i] > ....: > sage: F = Family({-1:0}) > sage: foo2(F, int(-1)) # This works > 0 > sage: foo(F, int(-1)) > KeyError: 0 > sage: F._dictionary > {-1: 0} > sage: foo(F, int(2)) # Expected failure, but the input matches > --------------------------------------------------------------------------- > KeyError Traceback (most recent call last > ) > ... > KeyError: 2 > > It seems to have to do with a __getitem__. I do not understand what > precisely the situation is that makes this fail; when I try to go to > smaller examples, it works. > > Indication of what might be happening: with your example upstairs I get >
sage: foo(F,-2) 0 sage: foo(F,-3) KeyError: -2 sage: foo(F,3) KeyError: 3 sage: foo(F,2**31) OverflowError: value too large to convert to int sage: foo(F,2**31-1) KeyError: 2147483647 sage: foo(F,-2**31) KeyError: -2147483647 so it looks like with "foo" something goes wrong with the conversion of signed ints. The boundary cases perhaps give an indication where this goes wrong. I'd think this is indeed a bug. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.