Merged revisions 56467-56482 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56477 | martin.v.loewis | 2007-07-21 09:04:38 +0200 (Sa, 21 Jul 2007) | 11 lines
Merged revisions 56466-56476 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56476 | martin.v.loewis | 2007-07-21 08:55:02 +0200 (Sa, 21 Jul 2007) | 4 lines
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
........
................
r56478 | martin.v.loewis | 2007-07-21 09:47:23 +0200 (Sa, 21 Jul 2007) | 2 lines
PEP 3123: Use proper C inheritance for PyObject.
................
r56479 | martin.v.loewis | 2007-07-21 10:06:55 +0200 (Sa, 21 Jul 2007) | 3 lines
Add longintrepr.h to Python.h, so that the compiler can
see that PyFalse is really some kind of PyObject*.
................
r56480 | martin.v.loewis | 2007-07-21 10:47:18 +0200 (Sa, 21 Jul 2007) | 2 lines
Qualify SHIFT, MASK, BASE.
................
r56482 | martin.v.loewis | 2007-07-21 19:10:57 +0200 (Sa, 21 Jul 2007) | 2 lines
Correctly refer to _ob_next.
................
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 8d4291b..cc60488 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -3,7 +3,7 @@
Written and maintained by Raymond D. Hettinger <python@rcn.com>
Derived from Lib/sets.py and Objects/dictobject.c.
- Copyright (c) 2003-6 Python Software Foundation.
+ Copyright (c) 2003-2007 Python Software Foundation.
All rights reserved.
*/
@@ -561,7 +561,7 @@
if (num_free_sets < MAXFREESETS && PyAnySet_CheckExact(so))
free_sets[num_free_sets++] = so;
else
- so->ob_type->tp_free(so);
+ Py_Type(so)->tp_free(so);
Py_TRASHCAN_SAFE_END(so)
}
@@ -578,21 +578,21 @@
if (status != 0) {
if (status < 0)
return status;
- fprintf(fp, "%s(...)", so->ob_type->tp_name);
+ fprintf(fp, "%s(...)", Py_Type(so)->tp_name);
return 0;
}
if (!so->used) {
Py_ReprLeave((PyObject*)so);
- fprintf(fp, "%s()", so->ob_type->tp_name);
+ fprintf(fp, "%s()", Py_Type(so)->tp_name);
return 0;
}
- if (so->ob_type == &PySet_Type) {
+ if (Py_Type(so) == &PySet_Type) {
literalform = 1;
fprintf(fp, "{");
} else
- fprintf(fp, "%s([", so->ob_type->tp_name);
+ fprintf(fp, "%s([", Py_Type(so)->tp_name);
while (set_next(so, &pos, &entry)) {
fputs(emit, fp);
emit = separator;
@@ -892,8 +892,7 @@
}
static PyTypeObject PySetIter_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"setiterator", /* tp_name */
sizeof(setiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -1019,7 +1018,7 @@
(type == &PySet_Type || type == &PyFrozenSet_Type)) {
so = free_sets[--num_free_sets];
assert (so != NULL && PyAnySet_CheckExact(so));
- so->ob_type = type;
+ Py_Type(so) = type;
_Py_NewReference((PyObject *)so);
EMPTY_TO_MINSIZE(so);
PyObject_GC_Track(so);
@@ -1145,8 +1144,8 @@
memcpy(b->smalltable, tab, sizeof(tab));
}
- if (PyType_IsSubtype(a->ob_type, &PyFrozenSet_Type) &&
- PyType_IsSubtype(b->ob_type, &PyFrozenSet_Type)) {
+ if (PyType_IsSubtype(Py_Type(a), &PyFrozenSet_Type) &&
+ PyType_IsSubtype(Py_Type(b), &PyFrozenSet_Type)) {
h = a->hash; a->hash = b->hash; b->hash = h;
} else {
a->hash = -1;
@@ -1157,7 +1156,7 @@
static PyObject *
set_copy(PySetObject *so)
{
- return make_new_set(so->ob_type, (PyObject *)so);
+ return make_new_set(Py_Type(so), (PyObject *)so);
}
static PyObject *
@@ -1235,7 +1234,7 @@
if ((PyObject *)so == other)
return set_copy(so);
- result = (PySetObject *)make_new_set(so->ob_type, NULL);
+ result = (PySetObject *)make_new_set(Py_Type(so), NULL);
if (result == NULL)
return NULL;
@@ -1422,7 +1421,7 @@
return NULL;
}
- result = make_new_set(so->ob_type, NULL);
+ result = make_new_set(Py_Type(so), NULL);
if (result == NULL)
return NULL;
@@ -1523,7 +1522,7 @@
Py_INCREF(other);
otherset = (PySetObject *)other;
} else {
- otherset = (PySetObject *)make_new_set(so->ob_type, other);
+ otherset = (PySetObject *)make_new_set(Py_Type(so), other);
if (otherset == NULL)
return NULL;
}
@@ -1554,7 +1553,7 @@
PyObject *rv;
PySetObject *otherset;
- otherset = (PySetObject *)make_new_set(so->ob_type, other);
+ otherset = (PySetObject *)make_new_set(Py_Type(so), other);
if (otherset == NULL)
return NULL;
rv = set_symmetric_difference_update(otherset, (PyObject *)so);
@@ -1821,7 +1820,7 @@
dict = Py_None;
Py_INCREF(dict);
}
- result = PyTuple_Pack(3, so->ob_type, args, dict);
+ result = PyTuple_Pack(3, Py_Type(so), args, dict);
done:
Py_XDECREF(args);
Py_XDECREF(keys);
@@ -1838,7 +1837,7 @@
if (!PyAnySet_Check(self))
return -1;
- if (!PyArg_UnpackTuple(args, self->ob_type->tp_name, 0, 1, &iterable))
+ if (!PyArg_UnpackTuple(args, Py_Type(self)->tp_name, 0, 1, &iterable))
return -1;
set_clear_internal(self);
self->hash = -1;
@@ -1952,8 +1951,7 @@
Build an unordered collection of unique elements.");
PyTypeObject PySet_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"set", /* tp_name */
sizeof(PySetObject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2046,8 +2044,7 @@
Build an immutable unordered collection of unique elements.");
PyTypeObject PyFrozenSet_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"frozenset", /* tp_name */
sizeof(PySetObject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2128,7 +2125,7 @@
int
PySet_Clear(PyObject *set)
{
- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2148,7 +2145,7 @@
int
PySet_Discard(PyObject *set, PyObject *key)
{
- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2158,7 +2155,7 @@
int
PySet_Add(PyObject *set, PyObject *key)
{
- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2199,7 +2196,7 @@
PyObject *
PySet_Pop(PyObject *set)
{
- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
PyErr_BadInternalCall();
return NULL;
}
@@ -2209,7 +2206,7 @@
int
_PySet_Update(PyObject *set, PyObject *iterable)
{
- if (!PyType_IsSubtype(set->ob_type, &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}