Issue 33031: Questionable code in OrderedDict definition (original) (raw)

The array of PyMethodDef for OrderedDict contains explicit definitions of methods like delitem, eq and init. The purpose is aligning docstrings with Python implementation. But this doesn't work. Slot wrappers replace these descriptors. And docstings are standard docstrings for corresponding slot wrappers.

Thus this code doesn't work. And it looks dangerous, since functions are casted to incompatible function types. Even if they are never used, the compiler (gcc 8) produces warnings (see ). May be this is even undefined behavior. In that case the compiler can generate arbitrary code.

I suggest to remove these definitions.