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: dictobject.c: inappropriate use of PySet_GET_SIZE?
Type: Stage:
Components: Interpreter Core Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: benjamin.peterson, oefe, rhettinger
Priority: high Keywords:

Created on 2008-06-28 21:31 by oefe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg68914 - (view) Author: Martina Oefelein (oefe) Date: 2008-06-28 21:31
The first use of PySet_GET_SIZE in dict_fromkeys (file dictobject.c) is applied to a PyDictObject. These seem to work by chance, as the PyDictObject and PySetObject have very 
similar structure so that it does not matter if you cast a PyDictObject* to a PySetObject*. But if their structure ever diverges, this would cause unpredictable behaviour.

Thus, this use of PySet_GET_SIZE should probably be replaced with a call of PyDict_Size.

(There are two more calls to PySet_GET_SIZE resp. _PySet_NextEntry in the same function, 
but these are OK as they actually apply to a set.)
msg68916 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-06-28 21:49
Will get this fixed-up.
msg68919 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-06-28 22:17
Fixed.  See r64577
Thanks for the report.
msg68926 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-06-28 23:12
I still see another instance of PySet_GET_SIZE on line 1274.
msg68928 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-06-28 23:31
That one is technically okay because "seq" really is a set.  But I'm 
okay with you changing it anyway.  It would be nice to see Py_SIZE used 
everywhere in preference to the type specific versions of the same 
macro.
History
Date User Action Args
2022-04-11 14:56:35adminsetgithub: 47480
2008-06-28 23:31:50rhettingersetmessages: + msg68928
2008-06-28 23:12:28benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg68926
2008-06-28 22:17:19rhettingersetstatus: open -> closed
resolution: fixed
messages: + msg68919
2008-06-28 21:49:13rhettingersetpriority: high
messages: + msg68916
2008-06-28 21:45:24rhettingersetassignee: rhettinger
nosy: + rhettinger
2008-06-28 21:34:37oefesetversions: + Python 2.6, Python 3.0
2008-06-28 21:31:45oefecreate