Ticket #2156: 2156-tripledict.patch

File 2156-tripledict.patch, 1.9 KB (added by robertwb, 13 years ago)
  • sage/structure/coerce_dict.pyx

    # HG changeset patch
    # User Robert Bradshaw <robertwb@math.washington.edu>
    # Date 1202523236 28800
    # Node ID 883a559974c62967e17660df468ef7bc9c341e40
    # Parent  7994ac1af415700517c8e95a384df1e2c2ca611b
    Update coerce dict to reflect cast change in Cython
    We really do want the PyObject* address here.
    
    diff -r 7994ac1af415 -r 883a559974c6 sage/structure/coerce_dict.pyx
    a b cdef class TripleDict: 
    229229        return self.get(k1, k2, k3)
    230230           
    231231    cdef get(self, k1, k2, k3):
    232         cdef Py_ssize_t h = (<Py_ssize_t>k1 + 13*<Py_ssize_t>k2 + 503*<Py_ssize_t>k3)
     232        cdef Py_ssize_t h = (<Py_ssize_t><void *>k1 + 13*<Py_ssize_t><void *>k2 + 503*<Py_ssize_t><void *>k3)
    233233        if h < 0: h = -h
    234234        cdef Py_ssize_t i
    235235        bucket = <object>PyList_GET_ITEM(self.buckets, h % PyList_GET_SIZE(self.buckets))
    cdef class TripleDict: 
    257257        self.set(k1, k2, k3, value)
    258258           
    259259    cdef set(self, k1, k2, k3, value):
    260         cdef Py_ssize_t h = (<Py_ssize_t>k1 + 13*<Py_ssize_t>k2 + 503*<Py_ssize_t>k3)
     260        cdef Py_ssize_t h = (<Py_ssize_t><void *>k1 + 13*<Py_ssize_t><void *>k2 + 503*<Py_ssize_t><void *>k3)
    261261        if h < 0: h = -h
    262262        cdef Py_ssize_t i
    263263        bucket = <object>PyList_GET_ITEM(self.buckets, h % PyList_GET_SIZE(self.buckets))
    cdef class TripleDict: 
    284284            k1, k2, k3 = k
    285285        except (TypeError,ValueError):
    286286            raise KeyError, k
    287         cdef Py_ssize_t h = (<Py_ssize_t>k1 + 13*<Py_ssize_t>k2 + 503*<Py_ssize_t>k3)
     287        cdef Py_ssize_t h = (<Py_ssize_t><void *>k1 + 13*<Py_ssize_t><void *>k2 + 503*<Py_ssize_t><void *>k3)
    288288        if h < 0: h = -h
    289289        cdef Py_ssize_t i
    290290        bucket = <object>PyList_GET_ITEM(self.buckets, h % PyList_GET_SIZE(self.buckets))