15 | | '''EDIT:''' I think the problem is that the `dict` type has its `tp_print` field set, so we inherit that routine. Ideally we should override it, but I don't think cython provides support for that. Bug report to cython? |
| 15 | '''EDIT:''' I think the problem is that the `dict` type has its `tp_print` field set, so we inherit that routine. Ideally we should override it, but I don't think cython provides support for that. Discussion on [https://groups.google.com/forum/?hl=en#!topic/cython-users/ktsXt_o4M0Q cython-users] has some details. We could hack our way around it by doing |
| 16 | {{{ |
| 17 | cdef extern from "Python.h": |
| 18 | ctypedef struct PyTypeObject: |
| 19 | void * tp_print |
| 20 | |
| 21 | cdef WeakValueDictionary(dict): |
| 22 | def __init__(self): |
| 23 | .... |
| 24 | |
| 25 | #clear the tp_print field on the type after PyType_Ready has executed on it. |
| 26 | (<PyTypeObject *><void *>WeakValueDictionary).tp_print = NULL |
| 27 | }}} |
| 28 | It feels like a horrible hack but it does have the desired effect. |