summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-06-23 22:18:27 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-06-23 22:18:27 (GMT)
commitbb78f57c1486e124e5dc5e585e6a136b8ca7ee24 (patch)
tree1b22ead2f53246c4c18afda19e9a8b6b78c56861 /Objects
parent788306a9ab780555732511d87298dbac3e8e5945 (diff)
downloadcpython-bb78f57c1486e124e5dc5e585e6a136b8ca7ee24.zip
cpython-bb78f57c1486e124e5dc5e585e6a136b8ca7ee24.tar.gz
cpython-bb78f57c1486e124e5dc5e585e6a136b8ca7ee24.tar.bz2
Use struct member (ht_type) instead of casting pointers.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index a2b1619..88b23c5 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2394,14 +2394,15 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
s++;
if (res == NULL)
- return NULL;
+ return NULL;
+ type = &res->ht_type;
res->ht_name = PyUnicode_FromString(s);
if (!res->ht_name)
goto fail;
res->ht_qualname = res->ht_name;
Py_INCREF(res->ht_qualname);
- res->ht_type.tp_name = spec->name;
- if (!res->ht_type.tp_name)
+ type->tp_name = spec->name;
+ if (!type->tp_name)
goto fail;
/* Adjust for empty tuple bases */
@@ -2436,7 +2437,6 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
goto fail;
}
- type = (PyTypeObject *)res;
/* Initialize essential fields */
type->tp_as_number = &res->as_number;
type->tp_as_sequence = &res->as_sequence;
@@ -2448,9 +2448,9 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
Py_INCREF(base);
type->tp_base = base;
- res->ht_type.tp_basicsize = spec->basicsize;
- res->ht_type.tp_itemsize = spec->itemsize;
- res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
+ type->tp_basicsize = spec->basicsize;
+ type->tp_itemsize = spec->itemsize;
+ type->tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
for (slot = spec->slots; slot->slot; slot++) {
if (slot->slot >= Py_ARRAY_LENGTH(slotoffsets)) {
@@ -2470,20 +2470,20 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
if (tp_doc == NULL)
goto fail;
memcpy(tp_doc, slot->pfunc, len);
- res->ht_type.tp_doc = tp_doc;
+ type->tp_doc = tp_doc;
}
}
- if (res->ht_type.tp_dictoffset) {
+ if (type->tp_dictoffset) {
res->ht_cached_keys = _PyDict_NewKeysForClass();
}
- if (res->ht_type.tp_dealloc == NULL) {
+ if (type->tp_dealloc == NULL) {
/* It's a heap type, so needs the heap types' dealloc.
subtype_dealloc will call the base type's tp_dealloc, if
necessary. */
- res->ht_type.tp_dealloc = subtype_dealloc;
+ type->tp_dealloc = subtype_dealloc;
}
- if (PyType_Ready(&res->ht_type) < 0)
+ if (PyType_Ready(type) < 0)
goto fail;
/* Set type.__module__ */