Hi, Guido van Rossum wrote:
On Tue, May 27, 2008 at 9:47 AM, Stefan Behnel
wrote: Could this function get a public interface? I do not think Cython is the only case where C code wants to modify a type after its creation, and copying the code over seems like a hack to me.
I'm fine with giving it a public interface. Please submit a patch with docs included.
Straight forward patch is attached (against 3.0a5). Works for me in Cython. I thought about a name like "Taint(t)" or "ClearTypeCache(t)", but then went with the coward solution of calling the function PyType_Modified() as it was (almost) named internally. BTW, I noticed that the code in typeobject.c uses "DECREF before set" two times, like this: method_cache[h].version = type->tp_version_tag; method_cache[h].value = res; /* borrowed */ Py_INCREF(name); Py_DECREF(method_cache[h].name); method_cache[h].name = name; During the call to Py_DECREF, the cache content is incorrect, so can't this run into the same problem that Py_CLEAR() aims to solve? I attached a patch for that, too, just in case. Stefan