This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Misuse of Py_SIZE in dict.fromkey()
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: methane, serhiy.storchaka, xiang.zhang
Priority: normal Keywords:

Created on 2017-03-21 06:02 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 747 merged serhiy.storchaka, 2017-03-21 06:03
PR 750 merged serhiy.storchaka, 2017-03-21 07:35
Messages (5)
msg289915 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-21 06:02
In dict.fromkeys() implementation when a dict is passed its size is determined by using the Py_SIZE macro. This is not correct since PyDictObject is not a PyVarObject (but see issue28988).
msg289922 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-03-21 07:11
How about 3.6, Serhiy? I see you treat this as a bugfix on the PR.
msg289924 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-21 07:39
Yes, I treat this as a bugfix but I hesitated about backporting it. Py_SIZE works "by accident" and we can't change the layout of PyDictObject structure in maintain branches.

I have backported the fix to 3.6, but not to other branches since PyDict_GET_SIZE was added in 3.6 and other branches would need modifying the patch.
msg289925 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-03-21 07:48
I think 3.6 is enough.
msg290115 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-24 20:09
New changeset af839fe2fef12dbbc8083fc7f01daee48a85a916 by Serhiy Storchaka in branch '3.6':
bpo-29864: Don't use Py_SIZE for dict object. (#747) (#750)
https://github.com/python/cpython/commit/af839fe2fef12dbbc8083fc7f01daee48a85a916
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74050
2017-03-24 20:09:03serhiy.storchakasetmessages: + msg290115
2017-03-21 07:48:33xiang.zhangsetmessages: + msg289925
versions: + Python 3.6
2017-03-21 07:39:17serhiy.storchakasetmessages: + msg289924
2017-03-21 07:35:32serhiy.storchakasetpull_requests: + pull_request664
2017-03-21 07:11:17xiang.zhangsetnosy: + xiang.zhang
messages: + msg289922
2017-03-21 06:53:59serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-03-21 06:03:30serhiy.storchakasetpull_requests: + pull_request661
2017-03-21 06:02:12serhiy.storchakacreate