summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-07-21 06:55:02 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-07-21 06:55:02 (GMT)
commit6819210b9e4e5719a6f7f9c1725f8fa70a8936f6 (patch)
tree456e2e6b3d9d71e966f3b0e419ecfe44ce3c1fdd /Objects/dictobject.c
parentb1994b4a5d0139a010eb0af1d6615a3df92fe786 (diff)
downloadcpython-6819210b9e4e5719a6f7f9c1725f8fa70a8936f6.zip
cpython-6819210b9e4e5719a6f7f9c1725f8fa70a8936f6.tar.gz
cpython-6819210b9e4e5719a6f7f9c1725f8fa70a8936f6.tar.bz2
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index bf2a11e..30b3598 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -204,7 +204,7 @@ PyDict_New(void)
if (num_free_dicts) {
mp = free_dicts[--num_free_dicts];
assert (mp != NULL);
- assert (mp->ob_type == &PyDict_Type);
+ assert (Py_Type(mp) == &PyDict_Type);
_Py_NewReference((PyObject *)mp);
if (mp->ma_fill) {
EMPTY_TO_MINSIZE(mp);
@@ -849,10 +849,10 @@ dict_dealloc(register dictobject *mp)
}
if (mp->ma_table != mp->ma_smalltable)
PyMem_DEL(mp->ma_table);
- if (num_free_dicts < MAXFREEDICTS && mp->ob_type == &PyDict_Type)
+ if (num_free_dicts < MAXFREEDICTS && Py_Type(mp) == &PyDict_Type)
free_dicts[num_free_dicts++] = mp;
else
- mp->ob_type->tp_free((PyObject *)mp);
+ Py_Type(mp)->tp_free((PyObject *)mp);
Py_TRASHCAN_SAFE_END(mp)
}
@@ -1011,7 +1011,7 @@ dict_subscript(dictobject *mp, register PyObject *key)
if (missing_str == NULL)
missing_str =
PyString_InternFromString("__missing__");
- missing = _PyType_Lookup(mp->ob_type, missing_str);
+ missing = _PyType_Lookup(Py_Type(mp), missing_str);
if (missing != NULL)
return PyObject_CallFunctionObjArgs(missing,
(PyObject *)mp, key, NULL);
@@ -2119,8 +2119,7 @@ PyDoc_STRVAR(dictionary_doc,
" in the keyword argument list. For example: dict(one=1, two=2)");
PyTypeObject PyDict_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dict",
sizeof(dictobject),
0,
@@ -2302,8 +2301,7 @@ fail:
}
PyTypeObject PyDictIterKey_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictionary-keyiterator", /* tp_name */
sizeof(dictiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2375,8 +2373,7 @@ fail:
}
PyTypeObject PyDictIterValue_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictionary-valueiterator", /* tp_name */
sizeof(dictiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2462,8 +2459,7 @@ fail:
}
PyTypeObject PyDictIterItem_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictionary-itemiterator", /* tp_name */
sizeof(dictiterobject), /* tp_basicsize */
0, /* tp_itemsize */