Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 42334:e70cdce0e8b2
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.
................
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sat, 21 Jul 2007 17:22:18 +0000 |
| parents | 8fc93215c0cc |
| children | d3a5c796c8ba |
line wrap: on
line diff
--- a/Objects/floatobject.c Sat Jul 21 00:25:15 2007 +0000 +++ b/Objects/floatobject.c Sat Jul 21 17:22:18 2007 +0000 @@ -41,8 +41,8 @@ p = &((PyFloatBlock *)p)->objects[0]; q = p + N_FLOATOBJECTS; while (--q > p) - q->ob_type = (struct _typeobject *)(q-1); - q->ob_type = NULL; + Py_Type(q) = (struct _typeobject *)(q-1); + Py_Type(q) = NULL; return p + N_FLOATOBJECTS - 1; } @@ -56,7 +56,7 @@ } /* Inline PyObject_New */ op = free_list; - free_list = (PyFloatObject *)op->ob_type; + free_list = (PyFloatObject *)Py_Type(op); PyObject_INIT(op, &PyFloat_Type); op->ob_fval = fval; return (PyObject *) op; @@ -156,11 +156,11 @@ float_dealloc(PyFloatObject *op) { if (PyFloat_CheckExact(op)) { - op->ob_type = (struct _typeobject *)free_list; + Py_Type(op) = (struct _typeobject *)free_list; free_list = op; } else - op->ob_type->tp_free((PyObject *)op); + Py_Type(op)->tp_free((PyObject *)op); } double @@ -178,7 +178,7 @@ return -1; } - if ((nb = op->ob_type->tp_as_number) == NULL || nb->nb_float == NULL) { + if ((nb = Py_Type(op)->tp_as_number) == NULL || nb->nb_float == NULL) { PyErr_SetString(PyExc_TypeError, "a float is required"); return -1; } @@ -880,7 +880,7 @@ if (!PyString_Check(arg)) { PyErr_Format(PyExc_TypeError, "__getformat__() argument must be string, not %.500s", - arg->ob_type->tp_name); + Py_Type(arg)->tp_name); return NULL; } s = PyString_AS_STRING(arg); @@ -1044,8 +1044,7 @@ }; PyTypeObject PyFloat_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, + PyVarObject_HEAD_INIT(&PyType_Type, 0) "float", sizeof(PyFloatObject), 0, @@ -1156,7 +1155,7 @@ for (i = 0, p = &list->objects[0]; i < N_FLOATOBJECTS; i++, p++) { - if (PyFloat_CheckExact(p) && p->ob_refcnt != 0) + if (PyFloat_CheckExact(p) && Py_Refcnt(p) != 0) frem++; } next = list->next; @@ -1167,8 +1166,8 @@ i < N_FLOATOBJECTS; i++, p++) { if (!PyFloat_CheckExact(p) || - p->ob_refcnt == 0) { - p->ob_type = (struct _typeobject *) + Py_Refcnt(p) == 0) { + Py_Type(p) = (struct _typeobject *) free_list; free_list = p; } @@ -1200,7 +1199,7 @@ i < N_FLOATOBJECTS; i++, p++) { if (PyFloat_CheckExact(p) && - p->ob_refcnt != 0) { + Py_Refcnt(p) != 0) { char buf[100]; format_float(buf, sizeof(buf), p, PREC_STR); /* XXX(twouters) cast refcount to @@ -1209,7 +1208,7 @@ */ fprintf(stderr, "# <float at %p, refcnt=%ld, val=%s>\n", - p, (long)p->ob_refcnt, buf); + p, (long)Py_Refcnt(p), buf); } } list = list->next;
