summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 3583bca..a725022 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -214,7 +214,7 @@ PyObject_Init(PyObject *op, PyTypeObject *tp)
if (op == NULL)
return PyErr_NoMemory();
/* Any changes should be reflected in PyObject_INIT (objimpl.h) */
- op->ob_type = tp;
+ Py_Type(op) = tp;
_Py_NewReference(op);
return op;
}
@@ -226,7 +226,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
return (PyVarObject *) PyErr_NoMemory();
/* Any changes should be reflected in PyObject_INIT_VAR */
op->ob_size = size;
- op->ob_type = tp;
+ Py_Type(op) = tp;
_Py_NewReference((PyObject *)op);
return op;
}
@@ -279,7 +279,7 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
universally available */
fprintf(fp, "<refcnt %ld at %p>",
(long)op->ob_refcnt, op);
- else if (op->ob_type->tp_print == NULL) {
+ else if (Py_Type(op)->tp_print == NULL) {
PyObject *s;
if (flags & Py_PRINT_RAW)
s = PyObject_Str(op);
@@ -294,7 +294,7 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
Py_XDECREF(s);
}
else
- ret = (*op->ob_type->tp_print)(op, fp, flags);
+ ret = (*Py_Type(op)->tp_print)(op, fp, flags);
}
if (ret == 0) {
if (ferror(fp)) {
@@ -334,7 +334,7 @@ _PyObject_Dump(PyObject* op)
"type : %s\n"
"refcount: %ld\n"
"address : %p\n",
- op->ob_type==NULL ? "NULL" : op->ob_type->tp_name,
+ Py_Type(op)==NULL ? "NULL" : Py_Type(op)->tp_name,
(long)op->ob_refcnt,
op);
}
@@ -354,7 +354,7 @@ PyObject_Repr(PyObject *v)
#endif
if (v == NULL)
return PyUnicode_FromString("<NULL>");
- else if (v->ob_type->tp_repr == NULL)
+ else if (Py_Type(v)->tp_repr == NULL)
return PyUnicode_FromFormat("<%s object at %p>", v->ob_type->tp_name, v);
else {
ress = (*v->ob_type->tp_repr)(v);
@@ -408,16 +408,16 @@ _PyObject_Str(PyObject *v)
Py_INCREF(v);
return v;
}
- if (v->ob_type->tp_str == NULL)
+ if (Py_Type(v)->tp_str == NULL)
return PyObject_Repr(v);
- res = (*v->ob_type->tp_str)(v);
+ res = (*Py_Type(v)->tp_str)(v);
if (res == NULL)
return NULL;
if (!(PyString_Check(res) || PyUnicode_Check(res))) {
PyErr_Format(PyExc_TypeError,
"__str__ returned non-string (type %.200s)",
- res->ob_type->tp_name);
+ Py_Type(res)->tp_name);
Py_DECREF(res);
return NULL;
}
@@ -486,8 +486,8 @@ PyObject_Unicode(PyObject *v)
res = v;
}
else {
- if (v->ob_type->tp_str != NULL)
- res = (*v->ob_type->tp_str)(v);
+ if (Py_Type(v)->tp_str != NULL)
+ res = (*Py_Type(v)->tp_str)(v);
else
res = PyObject_Repr(v);
}
@@ -849,8 +849,8 @@ PyObject_GetAttrString(PyObject *v, const char *name)
{
PyObject *w, *res;
- if (v->ob_type->tp_getattr != NULL)
- return (*v->ob_type->tp_getattr)(v, (char*)name);
+ if (Py_Type(v)->tp_getattr != NULL)
+ return (*Py_Type(v)->tp_getattr)(v, (char*)name);
w = PyUnicode_InternFromString(name);
if (w == NULL)
return NULL;
@@ -877,8 +877,8 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
PyObject *s;
int res;
- if (v->ob_type->tp_setattr != NULL)
- return (*v->ob_type->tp_setattr)(v, (char*)name, w);
+ if (Py_Type(v)->tp_setattr != NULL)
+ return (*Py_Type(v)->tp_setattr)(v, (char*)name, w);
s = PyUnicode_InternFromString(name);
if (s == NULL)
return -1;
@@ -890,9 +890,9 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
PyObject *
PyObject_GetAttr(PyObject *v, PyObject *name)
{
- PyTypeObject *tp = v->ob_type;
+ PyTypeObject *tp = Py_Type(v);
- if (!PyUnicode_Check(name)) {
+ if (!PyUnicode_Check(name)) {
PyErr_Format(PyExc_TypeError,
"attribute name must be string, not '%.200s'",
name->ob_type->tp_name);
@@ -923,7 +923,7 @@ PyObject_HasAttr(PyObject *v, PyObject *name)
int
PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
{
- PyTypeObject *tp = v->ob_type;
+ PyTypeObject *tp = Py_Type(v);
int err;
if (!PyUnicode_Check(name)) {
@@ -970,7 +970,7 @@ PyObject **
_PyObject_GetDictPtr(PyObject *obj)
{
Py_ssize_t dictoffset;
- PyTypeObject *tp = obj->ob_type;
+ PyTypeObject *tp = Py_Type(obj);
dictoffset = tp->tp_dictoffset;
if (dictoffset == 0)
@@ -1003,7 +1003,7 @@ PyObject_SelfIter(PyObject *obj)
PyObject *
PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
{
- PyTypeObject *tp = obj->ob_type;
+ PyTypeObject *tp = Py_Type(obj);
PyObject *descr = NULL;
PyObject *res = NULL;
descrgetfunc f;
@@ -1087,7 +1087,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
}
if (f != NULL) {
- res = f(descr, obj, (PyObject *)obj->ob_type);
+ res = f(descr, obj, (PyObject *)Py_Type(obj));
Py_DECREF(descr);
goto done;
}
@@ -1109,7 +1109,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
int
PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
{
- PyTypeObject *tp = obj->ob_type;
+ PyTypeObject *tp = Py_Type(obj);
PyObject *descr;
descrsetfunc f;
PyObject **dictptr;
@@ -1309,7 +1309,7 @@ _dir_locals(void)
if (!PyList_Check(names)) {
PyErr_Format(PyExc_TypeError,
"dir(): expected keys() of locals to be a list, "
- "not '%.200s'", names->ob_type->tp_name);
+ "not '%.200s'", Py_Type(names)->tp_name);
Py_DECREF(names);
return NULL;
}
@@ -1437,7 +1437,7 @@ _dir_object(PyObject *obj)
if (!PyList_Check(result)) {
PyErr_Format(PyExc_TypeError,
"__dir__() must return a list, not %.200s",
- result->ob_type->tp_name);
+ Py_Type(result)->tp_name);
Py_DECREF(result);
result = NULL;
}
@@ -1499,8 +1499,7 @@ none_dealloc(PyObject* ignore)
static PyTypeObject PyNone_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NoneType",
0,
0,
@@ -1517,7 +1516,8 @@ static PyTypeObject PyNone_Type = {
};
PyObject _Py_NoneStruct = {
- PyObject_HEAD_INIT(&PyNone_Type)
+ _PyObject_EXTRA_INIT
+ 1, &PyNone_Type
};
/* NotImplemented is an object that can be used to signal that an
@@ -1530,8 +1530,7 @@ NotImplemented_repr(PyObject *op)
}
static PyTypeObject PyNotImplemented_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
"NotImplementedType",
0,
0,
@@ -1548,7 +1547,8 @@ static PyTypeObject PyNotImplemented_Type = {
};
PyObject _Py_NotImplementedStruct = {
- PyObject_HEAD_INIT(&PyNotImplemented_Type)
+ _PyObject_EXTRA_INIT
+ 1, &PyNotImplemented_Type
};
void
@@ -1625,7 +1625,7 @@ _Py_ForgetReference(register PyObject *op)
void
_Py_Dealloc(PyObject *op)
{
- destructor dealloc = op->ob_type->tp_dealloc;
+ destructor dealloc = Py_Type(op)->tp_dealloc;
_Py_ForgetReference(op);
(*dealloc)(op);
}
@@ -1656,7 +1656,7 @@ _Py_PrintReferenceAddresses(FILE *fp)
fprintf(fp, "Remaining object addresses:\n");
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next)
fprintf(fp, "%p [%" PY_FORMAT_SIZE_T "d] %s\n", op,
- op->ob_refcnt, op->ob_type->tp_name);
+ op->ob_refcnt, Py_Type(op)->tp_name);
}
PyObject *
@@ -1674,7 +1674,7 @@ _Py_GetObjects(PyObject *self, PyObject *args)
return NULL;
for (i = 0; (n == 0 || i < n) && op != &refchain; i++) {
while (op == self || op == args || op == res || op == t ||
- (t != NULL && op->ob_type != (PyTypeObject *) t)) {
+ (t != NULL && Py_Type(op) != (PyTypeObject *) t)) {
op = op->_ob_next;
if (op == &refchain)
return res;
@@ -1817,7 +1817,7 @@ _PyTrash_destroy_chain(void)
{
while (_PyTrash_delete_later) {
PyObject *op = _PyTrash_delete_later;
- destructor dealloc = op->ob_type->tp_dealloc;
+ destructor dealloc = Py_Type(op)->tp_dealloc;
_PyTrash_delete_later =
(PyObject*) _Py_AS_GC(op)->gc.gc_prev;