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                                  Traceback (most recent call last)
<ipython-input-40-24a8cb5ebbd7> in <module>()
----> 1 foo(F, int(-Integer(1)))

/home/travis/.sage/temp/apricot/12631/spyx/
_home_travis__sage_temp_apricot_12631_tmp_VdWmJ3_spyx/
_home_travis__sage_temp_apricot_12631_tmp_VdWmJ3_spyx_0.pyx in 
_home_travis__sage_temp_apricot_12631_tmp_VdWmJ3_spyx_0.foo()
      1 def foo(F, int i):
----> 2     return F[i]
      3 def foo2(F, int i):
      4     return F._dictionary[i]

/home/travis/sage-build/local/lib/python2.7/site-packages/sage/sets/family.pyc 
in __getitem__(self, i)
    723             'a'
    724         """
--> 725         return self._dictionary[i]
    726 
    727     # For the pickle and copy modules

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.

sage: class Bar(SageObject):
....:     def __init__(self):
....:         self._dictionary = {-1:0}
....:     def __getitem__(self, x):
....:         print(x)
....:         return self._dictionary[x]
sage: foo(Bar(), int(-1))
-1
0

Any thoughts on this?

Best,
Travis


-- 
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.

Reply via email to