Mercurial > cpython-lru_cache-weakref
comparison Modules/arraymodule.c @ 39222:b0cdcbcc5f45
Get rid of most of the flags (in tp_flags) that keep track of various
variations of the type struct and its attachments. In Py3k, all type
structs have to have all fields -- no binary backwards compatibility.
Had to change the complex object to a new-style number!
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 27 Jul 2006 21:53:35 +0000 |
| parents | 29ae5e0fc348 |
| children | 654c380cf8b9 |
comparison
equal
deleted
inserted
replaced
| 38673:a19c20c5e5c7 | 39222:b0cdcbcc5f45 |
|---|---|
| 1568 PyString_ConcatAndDel(&s, t); | 1568 PyString_ConcatAndDel(&s, t); |
| 1569 PyString_ConcatAndDel(&s, PyString_FromString(")")); | 1569 PyString_ConcatAndDel(&s, PyString_FromString(")")); |
| 1570 return s; | 1570 return s; |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 #define HASINDEX(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_HAVE_INDEX) | |
| 1574 | |
| 1575 static PyObject* | 1573 static PyObject* |
| 1576 array_subscr(arrayobject* self, PyObject* item) | 1574 array_subscr(arrayobject* self, PyObject* item) |
| 1577 { | 1575 { |
| 1578 PyNumberMethods *nb = item->ob_type->tp_as_number; | 1576 PyNumberMethods *nb = item->ob_type->tp_as_number; |
| 1579 if (nb != NULL && HASINDEX(item) && nb->nb_index != NULL) { | 1577 if (nb != NULL && nb->nb_index != NULL) { |
| 1580 Py_ssize_t i = nb->nb_index(item); | 1578 Py_ssize_t i = nb->nb_index(item); |
| 1581 if (i==-1 && PyErr_Occurred()) { | 1579 if (i==-1 && PyErr_Occurred()) { |
| 1582 return NULL; | 1580 return NULL; |
| 1583 } | 1581 } |
| 1584 if (i < 0) | 1582 if (i < 0) |
| 1624 | 1622 |
| 1625 static int | 1623 static int |
| 1626 array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) | 1624 array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) |
| 1627 { | 1625 { |
| 1628 PyNumberMethods *nb = item->ob_type->tp_as_number; | 1626 PyNumberMethods *nb = item->ob_type->tp_as_number; |
| 1629 if (nb != NULL && HASINDEX(item) && nb->nb_index != NULL) { | 1627 if (nb != NULL && nb->nb_index != NULL) { |
| 1630 Py_ssize_t i = nb->nb_index(item); | 1628 Py_ssize_t i = nb->nb_index(item); |
| 1631 if (i==-1 && PyErr_Occurred()) | 1629 if (i==-1 && PyErr_Occurred()) |
| 1632 return -1; | 1630 return -1; |
| 1633 if (i < 0) | 1631 if (i < 0) |
| 1634 i += self->ob_size; | 1632 i += self->ob_size; |
| 1982 0, /* tp_call */ | 1980 0, /* tp_call */ |
| 1983 0, /* tp_str */ | 1981 0, /* tp_str */ |
| 1984 PyObject_GenericGetAttr, /* tp_getattro */ | 1982 PyObject_GenericGetAttr, /* tp_getattro */ |
| 1985 0, /* tp_setattro */ | 1983 0, /* tp_setattro */ |
| 1986 &array_as_buffer, /* tp_as_buffer*/ | 1984 &array_as_buffer, /* tp_as_buffer*/ |
| 1987 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ | 1985 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
| 1988 arraytype_doc, /* tp_doc */ | 1986 arraytype_doc, /* tp_doc */ |
| 1989 0, /* tp_traverse */ | 1987 0, /* tp_traverse */ |
| 1990 0, /* tp_clear */ | 1988 0, /* tp_clear */ |
| 1991 array_richcompare, /* tp_richcompare */ | 1989 array_richcompare, /* tp_richcompare */ |
| 1992 offsetof(arrayobject, weakreflist), /* tp_weaklistoffset */ | 1990 offsetof(arrayobject, weakreflist), /* tp_weaklistoffset */ |
