classification
Title: Questionable code in OrderedDict definition
Type: compile error Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.snow, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-03-08 18:39 by serhiy.storchaka, last changed 2018-04-09 18:47 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6120 merged serhiy.storchaka, 2018-03-15 07:36
PR 6433 merged serhiy.storchaka, 2018-04-09 17:19
Messages (3)
msg313452 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-03-08 18:39
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 issue33012). May be this is even undefined behavior. In that case the compiler can generate arbitrary code.

I suggest to remove these definitions.
msg315134 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-09 16:14
New changeset 827d49f3cf0296f1e267eae6834a977cf312cc1e by Serhiy Storchaka in branch 'master':
bpo-33031: Remove dead code in C implementation of OrderedDict. (GH-6120)
https://github.com/python/cpython/commit/827d49f3cf0296f1e267eae6834a977cf312cc1e
msg315146 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-09 18:46
New changeset b0f387d7ca126d486fc82744b8ec90c131230311 by Serhiy Storchaka in branch '3.7':
[3.7] bpo-33031: Remove dead code in C implementation of OrderedDict. (GH-6120) (GH-6433)
https://github.com/python/cpython/commit/b0f387d7ca126d486fc82744b8ec90c131230311
History
Date User Action Args
2018-04-09 18:47:41serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-04-09 18:46:47serhiy.storchakasetmessages: + msg315146
2018-04-09 17:19:27serhiy.storchakasetpull_requests: + pull_request6129
2018-04-09 16:14:31serhiy.storchakasetmessages: + msg315134
2018-03-15 12:10:15serhiy.storchakalinkissue33012 dependencies
2018-03-15 07:37:18serhiy.storchakasetstage: patch review
2018-03-15 07:36:47serhiy.storchakasetstage: patch review -> (no value)
versions: + Python 3.7
2018-03-15 07:36:21serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request5884
2018-03-08 18:39:09serhiy.storchakacreate