PEP 3123: Provide forward compatibility with Python 3.0, while keeping

backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
This commit is contained in:
Martin v. Löwis 2007-07-21 06:55:02 +00:00
parent b1994b4a5d
commit 6819210b9e
129 changed files with 1090 additions and 1250 deletions

View file

@ -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 */