You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Questionable code in OrderedDict definition #77212
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 bpo-33012). May be this is even undefined behavior. In that case the compiler can generate arbitrary code.
New changeset b0f387d by Serhiy Storchaka in branch '3.7':
[3.7] bpo-33031: Remove dead code in C implementation of OrderedDict. (GH-6120) (GH-6433) b0f387d
Activity
serhiy-storchaka commentedon Mar 8, 2018
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 bpo-33012). May be this is even undefined behavior. In that case the compiler can generate arbitrary code.
I suggest to remove these definitions.
serhiy-storchaka commentedon Apr 9, 2018
New changeset 827d49f by Serhiy Storchaka in branch 'master':
bpo-33031: Remove dead code in C implementation of OrderedDict. (GH-6120)
827d49f
serhiy-storchaka commentedon Apr 9, 2018
New changeset b0f387d by Serhiy Storchaka in branch '3.7':
[3.7] bpo-33031: Remove dead code in C implementation of OrderedDict. (GH-6120) (GH-6433)
b0f387d