summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-19 02:37:44 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-19 02:37:44 (GMT)
commite93237dfcc4ee4feee62adafb4e7899487ca864b (patch)
treeb78abc265e7fb10639492f62e4ffd0ce1bcc67af /Objects
parentd586559c31b77938b514cec99f2f8b431a34dff5 (diff)
downloadcpython-e93237dfcc4ee4feee62adafb4e7899487ca864b.zip
cpython-e93237dfcc4ee4feee62adafb4e7899487ca864b.tar.gz
cpython-e93237dfcc4ee4feee62adafb4e7899487ca864b.tar.bz2
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c8
-rw-r--r--Objects/enumobject.c6
-rw-r--r--Objects/exceptions.c24
-rw-r--r--Objects/fileobject.c2
-rw-r--r--Objects/floatobject.c24
-rw-r--r--Objects/frameobject.c2
-rw-r--r--Objects/funcobject.c8
-rw-r--r--Objects/genobject.c2
-rw-r--r--Objects/intobject.c24
-rw-r--r--Objects/listobject.c166
-rw-r--r--Objects/longobject.c178
-rw-r--r--Objects/moduleobject.c2
-rw-r--r--Objects/object.c68
-rw-r--r--Objects/setobject.c32
-rw-r--r--Objects/sliceobject.c2
-rw-r--r--Objects/stringobject.c128
-rw-r--r--Objects/structseq.c12
-rw-r--r--Objects/tupleobject.c72
-rw-r--r--Objects/typeobject.c180
-rw-r--r--Objects/unicodeobject.c22
-rw-r--r--Objects/weakrefobject.c24
21 files changed, 493 insertions, 493 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 365aac6..1035e5f 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -202,7 +202,7 @@ PyDict_New(void)
if (num_free_dicts) {
mp = free_dicts[--num_free_dicts];
assert (mp != NULL);
- assert (Py_Type(mp) == &PyDict_Type);
+ assert (Py_TYPE(mp) == &PyDict_Type);
_Py_NewReference((PyObject *)mp);
if (mp->ma_fill) {
EMPTY_TO_MINSIZE(mp);
@@ -868,10 +868,10 @@ dict_dealloc(register PyDictObject *mp)
}
if (mp->ma_table != mp->ma_smalltable)
PyMem_DEL(mp->ma_table);
- if (num_free_dicts < MAXFREEDICTS && Py_Type(mp) == &PyDict_Type)
+ if (num_free_dicts < MAXFREEDICTS && Py_TYPE(mp) == &PyDict_Type)
free_dicts[num_free_dicts++] = mp;
else
- Py_Type(mp)->tp_free((PyObject *)mp);
+ Py_TYPE(mp)->tp_free((PyObject *)mp);
Py_TRASHCAN_SAFE_END(mp)
}
@@ -1041,7 +1041,7 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
if (missing_str == NULL)
missing_str =
PyString_InternFromString("__missing__");
- missing = _PyType_Lookup(Py_Type(mp), missing_str);
+ missing = _PyType_Lookup(Py_TYPE(mp), missing_str);
if (missing != NULL)
return PyObject_CallFunctionObjArgs(missing,
(PyObject *)mp, key, NULL);
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index 0a3694d..230dba2 100644
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -46,7 +46,7 @@ enum_dealloc(enumobject *en)
Py_XDECREF(en->en_sit);
Py_XDECREF(en->en_result);
Py_XDECREF(en->en_longindex);
- Py_Type(en)->tp_free(en);
+ Py_TYPE(en)->tp_free(en);
}
static int
@@ -108,7 +108,7 @@ enum_next(enumobject *en)
PyObject *result = en->en_result;
PyObject *it = en->en_sit;
- next_item = (*Py_Type(it)->tp_iternext)(it);
+ next_item = (*Py_TYPE(it)->tp_iternext)(it);
if (next_item == NULL)
return NULL;
@@ -237,7 +237,7 @@ reversed_dealloc(reversedobject *ro)
{
PyObject_GC_UnTrack(ro);
Py_XDECREF(ro->seq);
- Py_Type(ro)->tp_free(ro);
+ Py_TYPE(ro)->tp_free(ro);
}
static int
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index f7c44e7..b1d5d0b 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -56,7 +56,7 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int
BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
{
- if (!_PyArg_NoKeywords(Py_Type(self)->tp_name, kwds))
+ if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
return -1;
Py_DECREF(self->args);
@@ -85,7 +85,7 @@ BaseException_dealloc(PyBaseExceptionObject *self)
{
_PyObject_GC_UNTRACK(self);
BaseException_clear(self);
- Py_Type(self)->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -129,7 +129,7 @@ BaseException_repr(PyBaseExceptionObject *self)
if (!repr_suffix)
return NULL;
- name = (char *)Py_Type(self)->tp_name;
+ name = (char *)Py_TYPE(self)->tp_name;
dot = strrchr(name, '.');
if (dot != NULL) name = dot+1;
@@ -148,9 +148,9 @@ static PyObject *
BaseException_reduce(PyBaseExceptionObject *self)
{
if (self->args && self->dict)
- return PyTuple_Pack(3, Py_Type(self), self->args, self->dict);
+ return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
else
- return PyTuple_Pack(2, Py_Type(self), self->args);
+ return PyTuple_Pack(2, Py_TYPE(self), self->args);
}
/*
@@ -478,7 +478,7 @@ SystemExit_dealloc(PySystemExitObject *self)
{
_PyObject_GC_UNTRACK(self);
SystemExit_clear(self);
- Py_Type(self)->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -583,7 +583,7 @@ EnvironmentError_dealloc(PyEnvironmentErrorObject *self)
{
_PyObject_GC_UNTRACK(self);
EnvironmentError_clear(self);
- Py_Type(self)->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -725,9 +725,9 @@ EnvironmentError_reduce(PyEnvironmentErrorObject *self)
Py_INCREF(args);
if (self->dict)
- res = PyTuple_Pack(3, Py_Type(self), args, self->dict);
+ res = PyTuple_Pack(3, Py_TYPE(self), args, self->dict);
else
- res = PyTuple_Pack(2, Py_Type(self), args);
+ res = PyTuple_Pack(2, Py_TYPE(self), args);
Py_DECREF(args);
return res;
}
@@ -780,7 +780,7 @@ WindowsError_dealloc(PyWindowsErrorObject *self)
{
_PyObject_GC_UNTRACK(self);
WindowsError_clear(self);
- Py_Type(self)->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -1054,7 +1054,7 @@ SyntaxError_dealloc(PySyntaxErrorObject *self)
{
_PyObject_GC_UNTRACK(self);
SyntaxError_clear(self);
- Py_Type(self)->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -1532,7 +1532,7 @@ UnicodeError_dealloc(PyUnicodeErrorObject *self)
{
_PyObject_GC_UNTRACK(self);
UnicodeError_clear(self);
- Py_Type(self)->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 4dd5c71..a5a42fc 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -406,7 +406,7 @@ file_dealloc(PyFileObject *f)
Py_XDECREF(f->f_mode);
Py_XDECREF(f->f_encoding);
drop_readahead(f);
- Py_Type(f)->tp_free((PyObject *)f);
+ Py_TYPE(f)->tp_free((PyObject *)f);
}
static PyObject *
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index c24b9c5..5d0b920 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -42,8 +42,8 @@ fill_free_list(void)
p = &((PyFloatBlock *)p)->objects[0];
q = p + N_FLOATOBJECTS;
while (--q > p)
- Py_Type(q) = (struct _typeobject *)(q-1);
- Py_Type(q) = NULL;
+ Py_TYPE(q) = (struct _typeobject *)(q-1);
+ Py_TYPE(q) = NULL;
return p + N_FLOATOBJECTS - 1;
}
@@ -103,7 +103,7 @@ PyFloat_FromDouble(double fval)
}
/* Inline PyObject_New */
op = free_list;
- free_list = (PyFloatObject *)Py_Type(op);
+ free_list = (PyFloatObject *)Py_TYPE(op);
PyObject_INIT(op, &PyFloat_Type);
op->ob_fval = fval;
return (PyObject *) op;
@@ -242,11 +242,11 @@ static void
float_dealloc(PyFloatObject *op)
{
if (PyFloat_CheckExact(op)) {
- Py_Type(op) = (struct _typeobject *)free_list;
+ Py_TYPE(op) = (struct _typeobject *)free_list;
free_list = op;
}
else
- Py_Type(op)->tp_free((PyObject *)op);
+ Py_TYPE(op)->tp_free((PyObject *)op);
}
double
@@ -264,7 +264,7 @@ PyFloat_AsDouble(PyObject *op)
return -1;
}
- if ((nb = Py_Type(op)->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;
}
@@ -1193,7 +1193,7 @@ float_getformat(PyTypeObject *v, PyObject* arg)
if (!PyString_Check(arg)) {
PyErr_Format(PyExc_TypeError,
"__getformat__() argument must be string, not %.500s",
- Py_Type(arg)->tp_name);
+ Py_TYPE(arg)->tp_name);
return NULL;
}
s = PyString_AS_STRING(arg);
@@ -1476,7 +1476,7 @@ PyFloat_Fini(void)
for (i = 0, p = &list->objects[0];
i < N_FLOATOBJECTS;
i++, p++) {
- if (PyFloat_CheckExact(p) && Py_Refcnt(p) != 0)
+ if (PyFloat_CheckExact(p) && Py_REFCNT(p) != 0)
frem++;
}
next = list->next;
@@ -1487,8 +1487,8 @@ PyFloat_Fini(void)
i < N_FLOATOBJECTS;
i++, p++) {
if (!PyFloat_CheckExact(p) ||
- Py_Refcnt(p) == 0) {
- Py_Type(p) = (struct _typeobject *)
+ Py_REFCNT(p) == 0) {
+ Py_TYPE(p) = (struct _typeobject *)
free_list;
free_list = p;
}
@@ -1520,7 +1520,7 @@ PyFloat_Fini(void)
i < N_FLOATOBJECTS;
i++, p++) {
if (PyFloat_CheckExact(p) &&
- Py_Refcnt(p) != 0) {
+ Py_REFCNT(p) != 0) {
char buf[100];
PyFloat_AsString(buf, p);
/* XXX(twouters) cast refcount to
@@ -1529,7 +1529,7 @@ PyFloat_Fini(void)
*/
fprintf(stderr,
"# <float at %p, refcnt=%ld, val=%s>\n",
- p, (long)Py_Refcnt(p), buf);
+ p, (long)Py_REFCNT(p), buf);
}
}
list = list->next;
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 3cb6a0d..be00caa 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -622,7 +622,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,
--numfree;
f = free_list;
free_list = free_list->f_back;
- if (Py_Size(f) < extras) {
+ if (Py_SIZE(f) < extras) {
f = PyObject_GC_Resize(PyFrameObject, f, extras);
if (f == NULL) {
Py_DECREF(builtins);
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 3efe8dd..a2e87b7 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -614,7 +614,7 @@ cm_dealloc(classmethod *cm)
{
_PyObject_GC_UNTRACK((PyObject *)cm);
Py_XDECREF(cm->cm_callable);
- Py_Type(cm)->tp_free((PyObject *)cm);
+ Py_TYPE(cm)->tp_free((PyObject *)cm);
}
static int
@@ -643,9 +643,9 @@ cm_descr_get(PyObject *self, PyObject *obj, PyObject *type)
return NULL;
}
if (type == NULL)
- type = (PyObject *)(Py_Type(obj));
+ type = (PyObject *)(Py_TYPE(obj));
return PyMethod_New(cm->cm_callable,
- type, (PyObject *)(Py_Type(type)));
+ type, (PyObject *)(Py_TYPE(type)));
}
static int
@@ -771,7 +771,7 @@ sm_dealloc(staticmethod *sm)
{
_PyObject_GC_UNTRACK((PyObject *)sm);
Py_XDECREF(sm->sm_callable);
- Py_Type(sm)->tp_free((PyObject *)sm);
+ Py_TYPE(sm)->tp_free((PyObject *)sm);
}
static int
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 551d9fd..4ef710b 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -28,7 +28,7 @@ gen_dealloc(PyGenObject *gen)
if (gen->gi_frame != NULL && gen->gi_frame->f_stacktop != NULL) {
/* Generator is paused, so we need to close */
- Py_Type(gen)->tp_del(self);
+ Py_TYPE(gen)->tp_del(self);
if (self->ob_refcnt > 0)
return; /* resurrected. :( */
}
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 364947e..0f11974 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -56,8 +56,8 @@ fill_free_list(void)
p = &((PyIntBlock *)p)->objects[0];
q = p + N_INTOBJECTS;
while (--q > p)
- Py_Type(q) = (struct _typeobject *)(q-1);
- Py_Type(q) = NULL;
+ Py_TYPE(q) = (struct _typeobject *)(q-1);
+ Py_TYPE(q) = NULL;
return p + N_INTOBJECTS - 1;
}
@@ -102,7 +102,7 @@ PyInt_FromLong(long ival)
}
/* Inline PyObject_New */
v = free_list;
- free_list = (PyIntObject *)Py_Type(v);
+ free_list = (PyIntObject *)Py_TYPE(v);
PyObject_INIT(v, &PyInt_Type);
v->ob_ival = ival;
return (PyObject *) v;
@@ -128,17 +128,17 @@ static void
int_dealloc(PyIntObject *v)
{
if (PyInt_CheckExact(v)) {
- Py_Type(v) = (struct _typeobject *)free_list;
+ Py_TYPE(v) = (struct _typeobject *)free_list;
free_list = v;
}
else
- Py_Type(v)->tp_free((PyObject *)v);
+ Py_TYPE(v)->tp_free((PyObject *)v);
}
static void
int_free(PyIntObject *v)
{
- Py_Type(v) = (struct _typeobject *)free_list;
+ Py_TYPE(v) = (struct _typeobject *)free_list;
free_list = v;
}
@@ -152,7 +152,7 @@ PyInt_AsLong(register PyObject *op)
if (op && PyInt_Check(op))
return PyInt_AS_LONG((PyIntObject*) op);
- if (op == NULL || (nb = Py_Type(op)->tp_as_number) == NULL ||
+ if (op == NULL || (nb = Py_TYPE(op)->tp_as_number) == NULL ||
nb->nb_int == NULL) {
PyErr_SetString(PyExc_TypeError, "an integer is required");
return -1;
@@ -207,7 +207,7 @@ PyInt_AsSsize_t(register PyObject *op)
return PyInt_AsLong(op);
#else
- if ((nb = Py_Type(op)->tp_as_number) == NULL ||
+ if ((nb = Py_TYPE(op)->tp_as_number) == NULL ||
(nb->nb_int == NULL && nb->nb_long == 0)) {
PyErr_SetString(PyExc_TypeError, "an integer is required");
return -1;
@@ -256,7 +256,7 @@ PyInt_AsUnsignedLongMask(register PyObject *op)
if (op && PyLong_Check(op))
return PyLong_AsUnsignedLongMask(op);
- if (op == NULL || (nb = Py_Type(op)->tp_as_number) == NULL ||
+ if (op == NULL || (nb = Py_TYPE(op)->tp_as_number) == NULL ||
nb->nb_int == NULL) {
PyErr_SetString(PyExc_TypeError, "an integer is required");
return (unsigned long)-1;
@@ -301,7 +301,7 @@ PyInt_AsUnsignedLongLongMask(register PyObject *op)
if (op && PyLong_Check(op))
return PyLong_AsUnsignedLongLongMask(op);
- if (op == NULL || (nb = Py_Type(op)->tp_as_number) == NULL ||
+ if (op == NULL || (nb = Py_TYPE(op)->tp_as_number) == NULL ||
nb->nb_int == NULL) {
PyErr_SetString(PyExc_TypeError, "an integer is required");
return (unsigned PY_LONG_LONG)-1;
@@ -1172,7 +1172,7 @@ _PyInt_Init(void)
return 0;
/* PyObject_New is inlined */
v = free_list;
- free_list = (PyIntObject *)Py_Type(v);
+ free_list = (PyIntObject *)Py_TYPE(v);
PyObject_INIT(v, &PyInt_Type);
v->ob_ival = ival;
small_ints[ival + NSMALLNEGINTS] = v;
@@ -1225,7 +1225,7 @@ PyInt_Fini(void)
ctr++, p++) {
if (!PyInt_CheckExact(p) ||
p->ob_refcnt == 0) {
- Py_Type(p) = (struct _typeobject *)
+ Py_TYPE(p) = (struct _typeobject *)
free_list;
free_list = p;
}
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 3fa256e..27f0a81 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -34,7 +34,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
*/
if (allocated >= newsize && newsize >= (allocated >> 1)) {
assert(self->ob_item != NULL || newsize == 0);
- Py_Size(self) = newsize;
+ Py_SIZE(self) = newsize;
return 0;
}
@@ -58,7 +58,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
return -1;
}
self->ob_item = items;
- Py_Size(self) = newsize;
+ Py_SIZE(self) = newsize;
self->allocated = new_allocated;
return 0;
}
@@ -114,7 +114,7 @@ PyList_New(Py_ssize_t size)
}
memset(op->ob_item, 0, nbytes);
}
- Py_Size(op) = size;
+ Py_SIZE(op) = size;
op->allocated = size;
_PyObject_GC_TRACK(op);
return (PyObject *) op;
@@ -128,7 +128,7 @@ PyList_Size(PyObject *op)
return -1;
}
else
- return Py_Size(op);
+ return Py_SIZE(op);
}
static PyObject *indexerr = NULL;
@@ -140,7 +140,7 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
PyErr_BadInternalCall();
return NULL;
}
- if (i < 0 || i >= Py_Size(op)) {
+ if (i < 0 || i >= Py_SIZE(op)) {
if (indexerr == NULL)
indexerr = PyString_FromString(
"list index out of range");
@@ -161,7 +161,7 @@ PyList_SetItem(register PyObject *op, register Py_ssize_t i,
PyErr_BadInternalCall();
return -1;
}
- if (i < 0 || i >= Py_Size(op)) {
+ if (i < 0 || i >= Py_SIZE(op)) {
Py_XDECREF(newitem);
PyErr_SetString(PyExc_IndexError,
"list assignment index out of range");
@@ -177,7 +177,7 @@ PyList_SetItem(register PyObject *op, register Py_ssize_t i,
static int
ins1(PyListObject *self, Py_ssize_t where, PyObject *v)
{
- Py_ssize_t i, n = Py_Size(self);
+ Py_ssize_t i, n = Py_SIZE(self);
PyObject **items;
if (v == NULL) {
PyErr_BadInternalCall();
@@ -259,7 +259,7 @@ list_dealloc(PyListObject *op)
There's a simple test case where somehow this reduces
thrashing when a *very* large list is created and
immediately deleted. */
- i = Py_Size(op);
+ i = Py_SIZE(op);
while (--i >= 0) {
Py_XDECREF(op->ob_item[i]);
}
@@ -268,7 +268,7 @@ list_dealloc(PyListObject *op)
if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op))
free_lists[num_free_lists++] = op;
else
- Py_Type(op)->tp_free((PyObject *)op);
+ Py_TYPE(op)->tp_free((PyObject *)op);
Py_TRASHCAN_SAFE_END(op)
}
@@ -290,7 +290,7 @@ list_print(PyListObject *op, FILE *fp, int flags)
Py_BEGIN_ALLOW_THREADS
fprintf(fp, "[");
Py_END_ALLOW_THREADS
- for (i = 0; i < Py_Size(op); i++) {
+ for (i = 0; i < Py_SIZE(op); i++) {
if (i > 0) {
Py_BEGIN_ALLOW_THREADS
fprintf(fp, ", ");
@@ -320,7 +320,7 @@ list_repr(PyListObject *v)
return i > 0 ? PyString_FromString("[...]") : NULL;
}
- if (Py_Size(v) == 0) {
+ if (Py_SIZE(v) == 0) {
result = PyString_FromString("[]");
goto Done;
}
@@ -331,7 +331,7 @@ list_repr(PyListObject *v)
/* Do repr() on each element. Note that this may mutate the list,
so must refetch the list size on each iteration. */
- for (i = 0; i < Py_Size(v); ++i) {
+ for (i = 0; i < Py_SIZE(v); ++i) {
int status;
if (Py_EnterRecursiveCall(" while getting the repr of a list"))
goto Done;
@@ -381,7 +381,7 @@ Done:
static Py_ssize_t
list_length(PyListObject *a)
{
- return Py_Size(a);
+ return Py_SIZE(a);
}
static int
@@ -390,7 +390,7 @@ list_contains(PyListObject *a, PyObject *el)
Py_ssize_t i;
int cmp;
- for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(a); ++i)
+ for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i),
Py_EQ);
return cmp;
@@ -399,7 +399,7 @@ list_contains(PyListObject *a, PyObject *el)
static PyObject *
list_item(PyListObject *a, Py_ssize_t i)
{
- if (i < 0 || i >= Py_Size(a)) {
+ if (i < 0 || i >= Py_SIZE(a)) {
if (indexerr == NULL)
indexerr = PyString_FromString(
"list index out of range");
@@ -418,12 +418,12 @@ list_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
Py_ssize_t i, len;
if (ilow < 0)
ilow = 0;
- else if (ilow > Py_Size(a))
- ilow = Py_Size(a);
+ else if (ilow > Py_SIZE(a))
+ ilow = Py_SIZE(a);
if (ihigh < ilow)
ihigh = ilow;
- else if (ihigh > Py_Size(a))
- ihigh = Py_Size(a);
+ else if (ihigh > Py_SIZE(a))
+ ihigh = Py_SIZE(a);
len = ihigh - ilow;
np = (PyListObject *) PyList_New(len);
if (np == NULL)
@@ -463,7 +463,7 @@ list_concat(PyListObject *a, PyObject *bb)
return NULL;
}
#define b ((PyListObject *)bb)
- size = Py_Size(a) + Py_Size(b);
+ size = Py_SIZE(a) + Py_SIZE(b);
if (size < 0)
return PyErr_NoMemory();
np = (PyListObject *) PyList_New(size);
@@ -472,14 +472,14 @@ list_concat(PyListObject *a, PyObject *bb)
}
src = a->ob_item;
dest = np->ob_item;
- for (i = 0; i < Py_Size(a); i++) {
+ for (i = 0; i < Py_SIZE(a); i++) {
PyObject *v = src[i];
Py_INCREF(v);
dest[i] = v;
}
src = b->ob_item;
- dest = np->ob_item + Py_Size(a);
- for (i = 0; i < Py_Size(b); i++) {
+ dest = np->ob_item + Py_SIZE(a);
+ for (i = 0; i < Py_SIZE(b); i++) {
PyObject *v = src[i];
Py_INCREF(v);
dest[i] = v;
@@ -498,8 +498,8 @@ list_repeat(PyListObject *a, Py_ssize_t n)
PyObject *elem;
if (n < 0)
n = 0;
- size = Py_Size(a) * n;
- if (n && size/n != Py_Size(a))
+ size = Py_SIZE(a) * n;
+ if (n && size/n != Py_SIZE(a))
return PyErr_NoMemory();
if (size == 0)
return PyList_New(0);
@@ -508,7 +508,7 @@ list_repeat(PyListObject *a, Py_ssize_t n)
return NULL;
items = np->ob_item;
- if (Py_Size(a) == 1) {
+ if (Py_SIZE(a) == 1) {
elem = a->ob_item[0];
for (i = 0; i < n; i++) {
items[i] = elem;
@@ -519,7 +519,7 @@ list_repeat(PyListObject *a, Py_ssize_t n)
p = np->ob_item;
items = a->ob_item;
for (i = 0; i < n; i++) {
- for (j = 0; j < Py_Size(a); j++) {
+ for (j = 0; j < Py_SIZE(a); j++) {
*p = items[j];
Py_INCREF(*p);
p++;
@@ -536,8 +536,8 @@ list_clear(PyListObject *a)
if (item != NULL) {
/* Because XDECREF can recursively invoke operations on
this list, we make it empty first. */
- i = Py_Size(a);
- Py_Size(a) = 0;
+ i = Py_SIZE(a);
+ Py_SIZE(a) = 0;
a->ob_item = NULL;
a->allocated = 0;
while (--i >= 0) {
@@ -583,7 +583,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
else {
if (a == b) {
/* Special case "a[i:j] = a" -- copy b first */
- v = list_slice(b, 0, Py_Size(b));
+ v = list_slice(b, 0, Py_SIZE(b));
if (v == NULL)
return result;
result = list_ass_slice(a, ilow, ihigh, v);
@@ -598,18 +598,18 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
}
if (ilow < 0)
ilow = 0;
- else if (ilow > Py_Size(a))
- ilow = Py_Size(a);
+ else if (ilow > Py_SIZE(a))
+ ilow = Py_SIZE(a);
if (ihigh < ilow)
ihigh = ilow;
- else if (ihigh > Py_Size(a))
- ihigh = Py_Size(a);
+ else if (ihigh > Py_SIZE(a))
+ ihigh = Py_SIZE(a);
norig = ihigh - ilow;
assert(norig >= 0);
d = n - norig;
- if (Py_Size(a) + d == 0) {
+ if (Py_SIZE(a) + d == 0) {
Py_XDECREF(v_as_SF);
return list_clear(a);
}
@@ -627,12 +627,12 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
if (d < 0) { /* Delete -d items */
memmove(&item[ihigh+d], &item[ihigh],
- (Py_Size(a) - ihigh)*sizeof(PyObject *));
- list_resize(a, Py_Size(a) + d);
+ (Py_SIZE(a) - ihigh)*sizeof(PyObject *));
+ list_resize(a, Py_SIZE(a) + d);
item = a->ob_item;
}
else if (d > 0) { /* Insert d items */
- k = Py_Size(a);
+ k = Py_SIZE(a);
if (list_resize(a, k+d) < 0)
goto Error;
item = a->ob_item;
@@ -707,7 +707,7 @@ static int
list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v)
{
PyObject *old_value;
- if (i < 0 || i >= Py_Size(a)) {
+ if (i < 0 || i >= Py_SIZE(a)) {
PyErr_SetString(PyExc_IndexError,
"list assignment index out of range");
return -1;
@@ -766,7 +766,7 @@ listextend(PyListObject *self, PyObject *b)
Py_DECREF(b);
Py_RETURN_NONE;
}
- m = Py_Size(self);
+ m = Py_SIZE(self);
if (list_resize(self, m + n) == -1) {
Py_DECREF(b);
return NULL;
@@ -795,14 +795,14 @@ listextend(PyListObject *self, PyObject *b)
/* Guess a result list size. */
n = _PyObject_LengthHint(b, 8);
- m = Py_Size(self);
+ m = Py_SIZE(self);
mn = m + n;
if (mn >= m) {
/* Make room. */
if (list_resize(self, mn) == -1)
goto error;
/* Make the list sane again. */
- Py_Size(self) = m;
+ Py_SIZE(self) = m;
}
/* Else m + n overflowed; on the chance that n lied, and there really
* is enough room, ignore it. If n was telling the truth, we'll
@@ -821,10 +821,10 @@ listextend(PyListObject *self, PyObject *b)
}
break;
}
- if (Py_Size(self) < self->allocated) {
+ if (Py_SIZE(self) < self->allocated) {
/* steals ref */
- PyList_SET_ITEM(self, Py_Size(self), item);
- ++Py_Size(self);
+ PyList_SET_ITEM(self, Py_SIZE(self), item);
+ ++Py_SIZE(self);
}
else {
int status = app1(self, item);
@@ -835,8 +835,8 @@ listextend(PyListObject *self, PyObject *b)
}
/* Cut back result list if initial guess was too large. */
- if (Py_Size(self) < self->allocated)
- list_resize(self, Py_Size(self)); /* shrinking can't fail */
+ if (Py_SIZE(self) < self->allocated)
+ list_resize(self, Py_SIZE(self)); /* shrinking can't fail */
Py_DECREF(it);
Py_RETURN_NONE;
@@ -875,20 +875,20 @@ listpop(PyListObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|n:pop", &i))
return NULL;
- if (Py_Size(self) == 0) {
+ if (Py_SIZE(self) == 0) {
/* Special-case most common failure cause */
PyErr_SetString(PyExc_IndexError, "pop from empty list");
return NULL;
}
if (i < 0)
- i += Py_Size(self);
- if (i < 0 || i >= Py_Size(self)) {
+ i += Py_SIZE(self);
+ if (i < 0 || i >= Py_SIZE(self)) {
PyErr_SetString(PyExc_IndexError, "pop index out of range");
return NULL;
}
v = self->ob_item[i];
- if (i == Py_Size(self) - 1) {
- status = list_resize(self, Py_Size(self) - 1);
+ if (i == Py_SIZE(self) - 1) {
+ status = list_resize(self, Py_SIZE(self) - 1);
assert(status >= 0);
return v; /* and v now owns the reference the list had */
}
@@ -2018,10 +2018,10 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
* sorting (allowing mutations during sorting is a core-dump
* factory, since ob_item may change).
*/
- saved_ob_size = Py_Size(self);
+ saved_ob_size = Py_SIZE(self);
saved_ob_item = self->ob_item;
saved_allocated = self->allocated;
- Py_Size(self) = 0;
+ Py_SIZE(self) = 0;
self->ob_item = NULL;
self->allocated = -1; /* any operation will reset it to >= 0 */
@@ -2127,8 +2127,8 @@ fail:
dsu_fail:
final_ob_item = self->ob_item;
- i = Py_Size(self);
- Py_Size(self) = saved_ob_size;
+ i = Py_SIZE(self);
+ Py_SIZE(self) = saved_ob_size;
self->ob_item = saved_ob_item;
self->allocated = saved_allocated;
if (final_ob_item != NULL) {
@@ -2163,8 +2163,8 @@ PyList_Sort(PyObject *v)
static PyObject *
listreverse(PyListObject *self)
{
- if (Py_Size(self) > 1)
- reverse_slice(self->ob_item, self->ob_item + Py_Size(self));
+ if (Py_SIZE(self) > 1)
+ reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self));
Py_RETURN_NONE;
}
@@ -2177,8 +2177,8 @@ PyList_Reverse(PyObject *v)
PyErr_BadInternalCall();
return -1;
}
- if (Py_Size(self) > 1)
- reverse_slice(self->ob_item, self->ob_item + Py_Size(self));
+ if (Py_SIZE(self) > 1)
+ reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self));
return 0;
}
@@ -2192,7 +2192,7 @@ PyList_AsTuple(PyObject *v)
PyErr_BadInternalCall();
return NULL;
}
- n = Py_Size(v);
+ n = Py_SIZE(v);
w = PyTuple_New(n);
if (w == NULL)
return NULL;
@@ -2210,7 +2210,7 @@ PyList_AsTuple(PyObject *v)
static PyObject *
listindex(PyListObject *self, PyObject *args)
{
- Py_ssize_t i, start=0, stop=Py_Size(self);
+ Py_ssize_t i, start=0, stop=Py_SIZE(self);
PyObject *v;
if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
@@ -2218,16 +2218,16 @@ listindex(PyListObject *self, PyObject *args)
_PyEval_SliceIndex, &stop))
return NULL;
if (start < 0) {
- start += Py_Size(self);
+ start += Py_SIZE(self);
if (start < 0)
start = 0;
}
if (stop < 0) {
- stop += Py_Size(self);
+ stop += Py_SIZE(self);
if (stop < 0)
stop = 0;
}
- for (i = start; i < stop && i < Py_Size(self); i++) {
+ for (i = start; i < stop && i < Py_SIZE(self); i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0)
return PyInt_FromSsize_t(i);
@@ -2244,7 +2244,7 @@ listcount(PyListObject *self, PyObject *v)
Py_ssize_t count = 0;
Py_ssize_t i;
- for (i = 0; i < Py_Size(self); i++) {
+ for (i = 0; i < Py_SIZE(self); i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0)
count++;
@@ -2259,7 +2259,7 @@ listremove(PyListObject *self, PyObject *v)
{
Py_ssize_t i;
- for (i = 0; i < Py_Size(self); i++) {
+ for (i = 0; i < Py_SIZE(self); i++) {
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
if (cmp > 0) {
if (list_ass_slice(self, i, i+1,
@@ -2279,7 +2279,7 @@ list_traverse(PyListObject *o, visitproc visit, void *arg)
{
Py_ssize_t i;
- for (i = Py_Size(o); --i >= 0; )
+ for (i = Py_SIZE(o); --i >= 0; )
Py_VISIT(o->ob_item[i]);
return 0;
}
@@ -2298,7 +2298,7 @@ list_richcompare(PyObject *v, PyObject *w, int op)
vl = (PyListObject *)v;
wl = (PyListObject *)w;
- if (Py_Size(vl) != Py_Size(wl) && (op == Py_EQ || op == Py_NE)) {
+ if (Py_SIZE(vl) != Py_SIZE(wl) && (op == Py_EQ || op == Py_NE)) {
/* Shortcut: if the lengths differ, the lists differ */
PyObject *res;
if (op == Py_EQ)
@@ -2310,7 +2310,7 @@ list_richcompare(PyObject *v, PyObject *w, int op)
}
/* Search for the first index where items are different */
- for (i = 0; i < Py_Size(vl) && i < Py_Size(wl); i++) {
+ for (i = 0; i < Py_SIZE(vl) && i < Py_SIZE(wl); i++) {
int k = PyObject_RichCompareBool(vl->ob_item[i],
wl->ob_item[i], Py_EQ);
if (k < 0)
@@ -2319,10 +2319,10 @@ list_richcompare(PyObject *v, PyObject *w, int op)
break;
}
- if (i >= Py_Size(vl) || i >= Py_Size(wl)) {
+ if (i >= Py_SIZE(vl) || i >= Py_SIZE(wl)) {
/* No more items to compare -- compare sizes */
- Py_ssize_t vs = Py_Size(vl);
- Py_ssize_t ws = Py_Size(wl);
+ Py_ssize_t vs = Py_SIZE(vl);
+ Py_ssize_t ws = Py_SIZE(wl);
int cmp;
PyObject *res;
switch (op) {
@@ -2366,8 +2366,8 @@ list_init(PyListObject *self, PyObject *args, PyObject *kw)
return -1;
/* Verify list invariants established by PyType_GenericAlloc() */
- assert(0 <= Py_Size(self));
- assert(Py_Size(self) <= self->allocated || self->allocated == -1);
+ assert(0 <= Py_SIZE(self));
+ assert(Py_SIZE(self) <= self->allocated || self->allocated == -1);
assert(self->ob_item != NULL ||
self->allocated == 0 || self->allocated == -1);
@@ -2464,7 +2464,7 @@ list_subscript(PyListObject* self, PyObject* item)
PyObject* it;
PyObject **src, **dest;
- if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
+ if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
&start, &stop, &step, &slicelength) < 0) {
return NULL;
}
@@ -2513,7 +2513,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
- if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
+ if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
&start, &stop, &step, &slicelength) < 0) {
return -1;
}
@@ -2561,8 +2561,8 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
garbage[i] = PyList_GET_ITEM(self, cur);
- if (cur + step >= Py_Size(self)) {
- lim = Py_Size(self) - cur - 1;
+ if (cur + step >= Py_SIZE(self)) {
+ lim = Py_SIZE(self) - cur - 1;
}
memmove(self->ob_item + cur - i,
@@ -2570,15 +2570,15 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
lim * sizeof(PyObject *));
}
cur = start + slicelength*step;
- if (cur < Py_Size(self)) {
+ if (cur < Py_SIZE(self)) {
memmove(self->ob_item + cur - slicelength,
self->ob_item + cur,
- (Py_Size(self) - cur) *
+ (Py_SIZE(self) - cur) *
sizeof(PyObject *));
}
- Py_Size(self) -= slicelength;
- list_resize(self, Py_Size(self));
+ Py_SIZE(self) -= slicelength;
+ list_resize(self, Py_SIZE(self));
for (i = 0; i < slicelength; i++) {
Py_DECREF(garbage[i]);
diff --git a/Objects/longobject.c b/Objects/longobject.c
index f14f298..85e862a 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -50,13 +50,13 @@ static PyObject *long_format(PyObject *aa, int base, int addL);
static PyLongObject *
long_normalize(register PyLongObject *v)
{
- Py_ssize_t j = ABS(Py_Size(v));
+ Py_ssize_t j = ABS(Py_SIZE(v));
Py_ssize_t i = j;
while (i > 0 && v->ob_digit[i-1] == 0)
--i;
if (i != j)
- Py_Size(v) = (Py_Size(v) < 0) ? -(i) : i;
+ Py_SIZE(v) = (Py_SIZE(v) < 0) ? -(i) : i;
return v;
}
@@ -147,7 +147,7 @@ PyLong_FromUnsignedLong(unsigned long ival)
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
- Py_Size(v) = ndigits;
+ Py_SIZE(v) = ndigits;
while (ival) {
*p++ = (digit)(ival & MASK);
ival >>= SHIFT;
@@ -189,7 +189,7 @@ PyLong_FromDouble(double dval)
frac = ldexp(frac, SHIFT);
}
if (neg)
- Py_Size(v) = -(Py_Size(v));
+ Py_SIZE(v) = -(Py_SIZE(v));
return (PyObject *)v;
}
@@ -323,7 +323,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
return (unsigned long) -1;
}
v = (PyLongObject *)vv;
- i = Py_Size(v);
+ i = Py_SIZE(v);
x = 0;
if (i < 0) {
PyErr_SetString(PyExc_OverflowError,
@@ -381,7 +381,7 @@ _PyLong_Sign(PyObject *vv)
assert(v != NULL);
assert(PyLong_Check(v));
- return Py_Size(v) == 0 ? 0 : (Py_Size(v) < 0 ? -1 : 1);
+ return Py_SIZE(v) == 0 ? 0 : (Py_SIZE(v) < 0 ? -1 : 1);
}
size_t
@@ -393,7 +393,7 @@ _PyLong_NumBits(PyObject *vv)
assert(v != NULL);
assert(PyLong_Check(v));
- ndigits = ABS(Py_Size(v));
+ ndigits = ABS(Py_SIZE(v));
assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
if (ndigits > 0) {
digit msd = v->ob_digit[ndigits - 1];
@@ -519,7 +519,7 @@ _PyLong_FromByteArray(const unsigned char* bytes, size_t n,
}
}
- Py_Size(v) = is_signed ? -idigit : idigit;
+ Py_SIZE(v) = is_signed ? -idigit : idigit;
return (PyObject *)long_normalize(v);
}
@@ -540,8 +540,8 @@ _PyLong_AsByteArray(PyLongObject* v,
assert(v != NULL && PyLong_Check(v));
- if (Py_Size(v) < 0) {
- ndigits = -(Py_Size(v));
+ if (Py_SIZE(v) < 0) {
+ ndigits = -(Py_SIZE(v));
if (!is_signed) {
PyErr_SetString(PyExc_TypeError,
"can't convert negative long to unsigned");
@@ -550,7 +550,7 @@ _PyLong_AsByteArray(PyLongObject* v,
do_twos_comp = 1;
}
else {
- ndigits = Py_Size(v);
+ ndigits = Py_SIZE(v);
do_twos_comp = 0;
}
@@ -686,7 +686,7 @@ _PyLong_AsScaledDouble(PyObject *vv, int *exponent)
return -1;
}
v = (PyLongObject *)vv;
- i = Py_Size(v);
+ i = Py_SIZE(v);
sign = 1;
if (i < 0) {
sign = -1;
@@ -847,7 +847,7 @@ PyLong_FromLongLong(PY_LONG_LONG ival)
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
- Py_Size(v) = negative ? -ndigits : ndigits;
+ Py_SIZE(v) = negative ? -ndigits : ndigits;
t = (unsigned PY_LONG_LONG)ival;
while (t) {
*p++ = (digit)(t & MASK);
@@ -875,7 +875,7 @@ PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival)
v = _PyLong_New(ndigits);
if (v != NULL) {
digit *p = v->ob_digit;
- Py_Size(v) = ndigits;
+ Py_SIZE(v) = ndigits;
while (ival) {
*p++ = (digit)(ival & MASK);
ival >>= SHIFT;
@@ -1117,7 +1117,7 @@ mul1(PyLongObject *a, wdigit n)
static PyLongObject *
muladd1(PyLongObject *a, wdigit n, wdigit extra)
{
- Py_ssize_t size_a = ABS(Py_Size(a));
+ Py_ssize_t size_a = ABS(Py_SIZE(a));
PyLongObject *z = _PyLong_New(size_a+1);
twodigits carry = extra;
Py_ssize_t i;
@@ -1163,7 +1163,7 @@ inplace_divrem1(digit *pout, digit *pin, Py_ssize_t size, digit n)
static PyLongObject *
divrem1(PyLongObject *a, digit n, digit *prem)
{
- const Py_ssize_t size = ABS(Py_Size(a));
+ const Py_ssize_t size = ABS(Py_SIZE(a));
PyLongObject *z;
assert(n > 0 && n <= MASK);
@@ -1194,7 +1194,7 @@ long_format(PyObject *aa, int base, int addL)
return NULL;
}
assert(base >= 2 && base <= 36);
- size_a = ABS(Py_Size(a));
+ size_a = ABS(Py_SIZE(a));
/* Compute a rough upper bound for the length of the string */
i = base;
@@ -1597,7 +1597,7 @@ digit beyond the first.
z = _PyLong_New(size_z);
if (z == NULL)
return NULL;
- Py_Size(z) = 0;
+ Py_SIZE(z) = 0;
/* `convwidth` consecutive input digits are treated as a single
* digit in base `convmultmax`.
@@ -1627,7 +1627,7 @@ digit beyond the first.
/* Multiply z by convmult, and add c. */
pz = z->ob_digit;
- pzstop = pz + Py_Size(z);
+ pzstop = pz + Py_SIZE(z);
for (; pz < pzstop; ++pz) {
c += (twodigits)*pz * convmult;
*pz = (digit)(c & MASK);
@@ -1636,14 +1636,14 @@ digit beyond the first.
/* carry off the current end? */
if (c) {
assert(c < BASE);
- if (Py_Size(z) < size_z) {
+ if (Py_SIZE(z) < size_z) {
*pz = (digit)c;
- ++Py_Size(z);
+ ++Py_SIZE(z);
}
else {
PyLongObject *tmp;
/* Extremely rare. Get more space. */
- assert(Py_Size(z) == size_z);
+ assert(Py_SIZE(z) == size_z);
tmp = _PyLong_New(size_z + 1);
if (tmp == NULL) {
Py_DECREF(z);
@@ -1665,7 +1665,7 @@ digit beyond the first.
if (str == start)
goto onError;
if (sign < 0)
- Py_Size(z) = -(Py_Size(z));
+ Py_SIZE(z) = -(Py_SIZE(z));
if (*str == 'L' || *str == 'l')
str++;
while (*str && isspace(Py_CHARMASK(*str)))
@@ -1726,7 +1726,7 @@ static int
long_divrem(PyLongObject *a, PyLongObject *b,
PyLongObject **pdiv, PyLongObject **prem)
{
- Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
PyLongObject *z;
if (size_b == 0) {
@@ -1778,7 +1778,7 @@ long_divrem(PyLongObject *a, PyLongObject *b,
static PyLongObject *
x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
{
- Py_ssize_t size_v = ABS(Py_Size(v1)), size_w = ABS(Py_Size(w1));
+ Py_ssize_t size_v = ABS(Py_SIZE(v1)), size_w = ABS(Py_SIZE(w1));
digit d = (digit) ((twodigits)BASE / (w1->ob_digit[size_w-1] + 1));
PyLongObject *v = mul1(v1, d);
PyLongObject *w = mul1(w1, d);
@@ -1792,10 +1792,10 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
}
assert(size_v >= size_w && size_w > 1); /* Assert checks by div() */
- assert(Py_Refcnt(v) == 1); /* Since v will be used as accumulator! */
- assert(size_w == ABS(Py_Size(w))); /* That's how d was calculated */
+ assert(Py_REFCNT(v) == 1); /* Since v will be used as accumulator! */
+ assert(size_w == ABS(Py_SIZE(w))); /* That's how d was calculated */
- size_v = ABS(Py_Size(v));
+ size_v = ABS(Py_SIZE(v));
k = size_v - size_w;
a = _PyLong_New(k + 1);
@@ -1878,7 +1878,7 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
static void
long_dealloc(PyObject *v)
{
- Py_Type(v)->tp_free(v);
+ Py_TYPE(v)->tp_free(v);
}
static PyObject *
@@ -1898,21 +1898,21 @@ long_compare(PyLongObject *a, PyLongObject *b)
{
Py_ssize_t sign;
- if (Py_Size(a) != Py_Size(b)) {
- if (ABS(Py_Size(a)) == 0 && ABS(Py_Size(b)) == 0)
+ if (Py_SIZE(a) != Py_SIZE(b)) {
+ if (ABS(Py_SIZE(a)) == 0 && ABS(Py_SIZE(b)) == 0)
sign = 0;
else
- sign = Py_Size(a) - Py_Size(b);
+ sign = Py_SIZE(a) - Py_SIZE(b);
}
else {
- Py_ssize_t i = ABS(Py_Size(a));
+ Py_ssize_t i = ABS(Py_SIZE(a));
while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
;
if (i < 0)
sign = 0;
else {
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
- if (Py_Size(a) < 0)
+ if (Py_SIZE(a) < 0)
sign = -sign;
}
}
@@ -1963,7 +1963,7 @@ long_hash(PyLongObject *v)
static PyLongObject *
x_add(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
PyLongObject *z;
int i;
digit carry = 0;
@@ -1997,7 +1997,7 @@ x_add(PyLongObject *a, PyLongObject *b)
static PyLongObject *
x_sub(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
PyLongObject *z;
Py_ssize_t i;
int sign = 1;
@@ -2107,15 +2107,15 @@ static PyLongObject *
x_mul(PyLongObject *a, PyLongObject *b)
{
PyLongObject *z;
- Py_ssize_t size_a = ABS(Py_Size(a));
- Py_ssize_t size_b = ABS(Py_Size(b));
+ Py_ssize_t size_a = ABS(Py_SIZE(a));
+ Py_ssize_t size_b = ABS(Py_SIZE(b));
Py_ssize_t i;
z = _PyLong_New(size_a + size_b);
if (z == NULL)
return NULL;
- memset(z->ob_digit, 0, Py_Size(z) * sizeof(digit));
+ memset(z->ob_digit, 0, Py_SIZE(z) * sizeof(digit));
if (a == b) {
/* Efficient squaring per HAC, Algorithm 14.16:
* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
@@ -2199,7 +2199,7 @@ kmul_split(PyLongObject *n, Py_ssize_t size, PyLongObject **high, PyLongObject *
{
PyLongObject *hi, *lo;
Py_ssize_t size_lo, size_hi;
- const Py_ssize_t size_n = ABS(Py_Size(n));
+ const Py_ssize_t size_n = ABS(Py_SIZE(n));
size_lo = MIN(size_n, size);
size_hi = size_n - size_lo;
@@ -2228,8 +2228,8 @@ static PyLongObject *k_lopsided_mul(PyLongObject *a, PyLongObject *b);
static PyLongObject *
k_mul(PyLongObject *a, PyLongObject *b)
{
- Py_ssize_t asize = ABS(Py_Size(a));
- Py_ssize_t bsize = ABS(Py_Size(b));
+ Py_ssize_t asize = ABS(Py_SIZE(a));
+ Py_ssize_t bsize = ABS(Py_SIZE(b));
PyLongObject *ah = NULL;
PyLongObject *al = NULL;
PyLongObject *bh = NULL;
@@ -2281,7 +2281,7 @@ k_mul(PyLongObject *a, PyLongObject *b)
/* Split a & b into hi & lo pieces. */
shift = bsize >> 1;
if (kmul_split(a, shift, &ah, &al) < 0) goto fail;
- assert(Py_Size(ah) > 0); /* the split isn't degenerate */
+ assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */
if (a == b) {
bh = ah;
@@ -2312,20 +2312,20 @@ k_mul(PyLongObject *a, PyLongObject *b)
if (ret == NULL) goto fail;
#ifdef Py_DEBUG
/* Fill with trash, to catch reference to uninitialized digits. */
- memset(ret->ob_digit, 0xDF, Py_Size(ret) * sizeof(digit));
+ memset(ret->ob_digit, 0xDF, Py_SIZE(ret) * sizeof(digit));
#endif
/* 2. t1 <- ah*bh, and copy into high digits of result. */
if ((t1 = k_mul(ah, bh)) == NULL) goto fail;
- assert(Py_Size(t1) >= 0);
- assert(2*shift + Py_Size(t1) <= Py_Size(ret));
+ assert(Py_SIZE(t1) >= 0);
+ assert(2*shift + Py_SIZE(t1) <= Py_SIZE(ret));
memcpy(ret->ob_digit + 2*shift, t1->ob_digit,
- Py_Size(t1) * sizeof(digit));
+ Py_SIZE(t1) * sizeof(digit));
/* Zero-out the digits higher than the ah*bh copy. */
- i = Py_Size(ret) - 2*shift - Py_Size(t1);
+ i = Py_SIZE(ret) - 2*shift - Py_SIZE(t1);
if (i)
- memset(ret->ob_digit + 2*shift + Py_Size(t1), 0,
+ memset(ret->ob_digit + 2*shift + Py_SIZE(t1), 0,
i * sizeof(digit));
/* 3. t2 <- al*bl, and copy into the low digits. */
@@ -2333,23 +2333,23 @@ k_mul(PyLongObject *a, PyLongObject *b)
Py_DECREF(t1);
goto fail;
}
- assert(Py_Size(t2) >= 0);
- assert(Py_Size(t2) <= 2*shift); /* no overlap with high digits */
- memcpy(ret->ob_digit, t2->ob_digit, Py_Size(t2) * sizeof(digit));
+ assert(Py_SIZE(t2) >= 0);
+ assert(Py_SIZE(t2) <= 2*shift); /* no overlap with high digits */
+ memcpy(ret->ob_digit, t2->ob_digit, Py_SIZE(t2) * sizeof(digit));
/* Zero out remaining digits. */
- i = 2*shift - Py_Size(t2); /* number of uninitialized digits */
+ i = 2*shift - Py_SIZE(t2); /* number of uninitialized digits */
if (i)
- memset(ret->ob_digit + Py_Size(t2), 0, i * sizeof(digit));
+ memset(ret->ob_digit + Py_SIZE(t2), 0, i * sizeof(digit));
/* 4 & 5. Subtract ah*bh (t1) and al*bl (t2). We do al*bl first
* because it's fresher in cache.
*/
- i = Py_Size(ret) - shift; /* # digits after shift */
- (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_Size(t2));
+ i = Py_SIZE(ret) - shift; /* # digits after shift */
+ (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_SIZE(t2));
Py_DECREF(t2);
- (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_Size(t1));
+ (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_SIZE(t1));
Py_DECREF(t1);
/* 6. t3 <- (ah+al)(bh+bl), and add into result. */
@@ -2374,12 +2374,12 @@ k_mul(PyLongObject *a, PyLongObject *b)
Py_DECREF(t1);
Py_DECREF(t2);
if (t3 == NULL) goto fail;
- assert(Py_Size(t3) >= 0);
+ assert(Py_SIZE(t3) >= 0);
/* Add t3. It's not obvious why we can't run out of room here.
* See the (*) comment after this function.
*/
- (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_Size(t3));
+ (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_SIZE(t3));
Py_DECREF(t3);
return long_normalize(ret);
@@ -2449,8 +2449,8 @@ ah*bh and al*bl too.
static PyLongObject *
k_lopsided_mul(PyLongObject *a, PyLongObject *b)
{
- const Py_ssize_t asize = ABS(Py_Size(a));
- Py_ssize_t bsize = ABS(Py_Size(b));
+ const Py_ssize_t asize = ABS(Py_SIZE(a));
+ Py_ssize_t bsize = ABS(Py_SIZE(b));
Py_ssize_t nbdone; /* # of b digits already multiplied */
PyLongObject *ret;
PyLongObject *bslice = NULL;
@@ -2462,7 +2462,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
ret = _PyLong_New(asize + bsize);
if (ret == NULL)
return NULL;
- memset(ret->ob_digit, 0, Py_Size(ret) * sizeof(digit));
+ memset(ret->ob_digit, 0, Py_SIZE(ret) * sizeof(digit));
/* Successive slices of b are copied into bslice. */
bslice = _PyLong_New(asize);
@@ -2477,14 +2477,14 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
/* Multiply the next slice of b by a. */
memcpy(bslice->ob_digit, b->ob_digit + nbdone,
nbtouse * sizeof(digit));
- Py_Size(bslice) = nbtouse;
+ Py_SIZE(bslice) = nbtouse;
product = k_mul(a, bslice);
if (product == NULL)
goto fail;
/* Add into result. */
- (void)v_iadd(ret->ob_digit + nbdone, Py_Size(ret) - nbdone,
- product->ob_digit, Py_Size(product));
+ (void)v_iadd(ret->ob_digit + nbdone, Py_SIZE(ret) - nbdone,
+ product->ob_digit, Py_SIZE(product));
Py_DECREF(product);
bsize -= nbtouse;
@@ -2548,8 +2548,8 @@ l_divmod(PyLongObject *v, PyLongObject *w,
if (long_divrem(v, w, &div, &mod) < 0)
return -1;
- if ((Py_Size(mod) < 0 && Py_Size(w) > 0) ||
- (Py_Size(mod) > 0 && Py_Size(w) < 0)) {
+ if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) ||
+ (Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) {
PyLongObject *temp;
PyLongObject *one;
temp = (PyLongObject *) long_add(mod, w);
@@ -2737,7 +2737,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
return Py_NotImplemented;
}
- if (Py_Size(b) < 0) { /* if exponent is negative */
+ if (Py_SIZE(b) < 0) { /* if exponent is negative */
if (c) {
PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
"cannot be negative when 3rd argument specified");
@@ -2756,7 +2756,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
if (c) {
/* if modulus == 0:
raise ValueError() */
- if (Py_Size(c) == 0) {
+ if (Py_SIZE(c) == 0) {
PyErr_SetString(PyExc_ValueError,
"pow() 3rd argument cannot be 0");
goto Error;
@@ -2765,7 +2765,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
/* if modulus < 0:
negativeOutput = True
modulus = -modulus */
- if (Py_Size(c) < 0) {
+ if (Py_SIZE(c) < 0) {
negativeOutput = 1;
temp = (PyLongObject *)_PyLong_Copy(c);
if (temp == NULL)
@@ -2778,7 +2778,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
/* if modulus == 1:
return 0 */
- if ((Py_Size(c) == 1) && (c->ob_digit[0] == 1)) {
+ if ((Py_SIZE(c) == 1) && (c->ob_digit[0] == 1)) {
z = (PyLongObject *)PyLong_FromLong(0L);
goto Done;
}
@@ -2786,7 +2786,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
/* if base < 0:
base = base % modulus
Having the base positive just makes things easier. */
- if (Py_Size(a) < 0) {
+ if (Py_SIZE(a) < 0) {
if (l_divmod(a, c, NULL, &temp) < 0)
goto Error;
Py_DECREF(a);
@@ -2827,10 +2827,10 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
REDUCE(result) \
}
- if (Py_Size(b) <= FIVEARY_CUTOFF) {
+ if (Py_SIZE(b) <= FIVEARY_CUTOFF) {
/* Left-to-right binary exponentiation (HAC Algorithm 14.79) */
/* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf */
- for (i = Py_Size(b) - 1; i >= 0; --i) {
+ for (i = Py_SIZE(b) - 1; i >= 0; --i) {
digit bi = b->ob_digit[i];
for (j = 1 << (SHIFT-1); j != 0; j >>= 1) {
@@ -2847,7 +2847,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
for (i = 1; i < 32; ++i)
MULT(table[i-1], a, table[i])
- for (i = Py_Size(b) - 1; i >= 0; --i) {
+ for (i = Py_SIZE(b) - 1; i >= 0; --i) {
const digit bi = b->ob_digit[i];
for (j = SHIFT - 5; j >= 0; j -= 5) {
@@ -2860,7 +2860,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
}
}
- if (negativeOutput && (Py_Size(z) != 0)) {
+ if (negativeOutput && (Py_SIZE(z) != 0)) {
temp = (PyLongObject *)long_sub(z, c);
if (temp == NULL)
goto Error;
@@ -2877,7 +2877,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
}
/* fall through */
Done:
- if (Py_Size(b) > FIVEARY_CUTOFF) {
+ if (Py_SIZE(b) > FIVEARY_CUTOFF) {
for (i = 0; i < 32; ++i)
Py_XDECREF(table[i]);
}
@@ -2901,7 +2901,7 @@ long_invert(PyLongObject *v)
Py_DECREF(w);
if (x == NULL)
return NULL;
- Py_Size(x) = -(Py_Size(x));
+ Py_SIZE(x) = -(Py_SIZE(x));
return (PyObject *)x;
}
@@ -2943,7 +2943,7 @@ long_abs(PyLongObject *v)
static int
long_nonzero(PyLongObject *v)
{
- return ABS(Py_Size(v)) != 0;
+ return ABS(Py_SIZE(v)) != 0;
}
static PyObject *
@@ -2957,7 +2957,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b);
- if (Py_Size(a) < 0) {
+ if (Py_SIZE(a) < 0) {
/* Right shifting negative numbers is harder */
PyLongObject *a1, *a2;
a1 = (PyLongObject *) long_invert(a);
@@ -2981,7 +2981,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
goto rshift_error;
}
wordshift = shiftby / SHIFT;
- newsize = ABS(Py_Size(a)) - wordshift;
+ newsize = ABS(Py_SIZE(a)) - wordshift;
if (newsize <= 0) {
z = _PyLong_New(0);
Py_DECREF(a);
@@ -2995,8 +2995,8 @@ long_rshift(PyLongObject *v, PyLongObject *w)
z = _PyLong_New(newsize);
if (z == NULL)
goto rshift_error;
- if (Py_Size(a) < 0)
- Py_Size(z) = -(Py_Size(z));
+ if (Py_SIZE(a) < 0)
+ Py_SIZE(z) = -(Py_SIZE(z));
for (i = 0, j = wordshift; i < newsize; i++, j++) {
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
if (i+1 < newsize)
@@ -3084,7 +3084,7 @@ long_bitwise(PyLongObject *a,
digit diga, digb;
PyObject *v;
- if (Py_Size(a) < 0) {
+ if (Py_SIZE(a) < 0) {
a = (PyLongObject *) long_invert(a);
if (a == NULL)
return NULL;
@@ -3094,7 +3094,7 @@ long_bitwise(PyLongObject *a,
Py_INCREF(a);
maska = 0;
}
- if (Py_Size(b) < 0) {
+ if (Py_SIZE(b) < 0) {
b = (PyLongObject *) long_invert(b);
if (b == NULL) {
Py_DECREF(a);
@@ -3143,8 +3143,8 @@ long_bitwise(PyLongObject *a,
whose length should be ignored.
*/
- size_a = Py_Size(a);
- size_b = Py_Size(b);
+ size_a = Py_SIZE(a);
+ size_b = Py_SIZE(b);
size_z = op == '&'
? (maska
? size_b
@@ -3351,7 +3351,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (tmp == NULL)
return NULL;
assert(PyLong_CheckExact(tmp));
- n = Py_Size(tmp);
+ n = Py_SIZE(tmp);
if (n < 0)
n = -n;
newobj = (PyLongObject *)type->tp_alloc(type, n);
@@ -3360,7 +3360,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
assert(PyLong_Check(newobj));
- Py_Size(newobj) = Py_Size(tmp);
+ Py_SIZE(newobj) = Py_SIZE(tmp);
for (i = 0; i < n; i++)
newobj->ob_digit[i] = tmp->ob_digit[i];
Py_DECREF(tmp);
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 5e3c293..d1aa771 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -178,7 +178,7 @@ module_dealloc(PyModuleObject *m)
_PyModule_Clear((PyObject *)m);
Py_DECREF(m->md_dict);
}
- Py_Type(m)->tp_free((PyObject *)m);
+ Py_TYPE(m)->tp_free((PyObject *)m);
}
static PyObject *
diff --git a/Objects/object.c b/Objects/object.c
index de385ea..788e732 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) */
- Py_Type(op) = 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;
- Py_Type(op) = tp;
+ Py_TYPE(op) = tp;
_Py_NewReference((PyObject *)op);
return op;
}
@@ -291,7 +291,7 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
fprintf(fp, "<refcnt %ld at %p>",
(long)op->ob_refcnt, op);
Py_END_ALLOW_THREADS
- else if (Py_Type(op)->tp_print == NULL) {
+ else if (Py_TYPE(op)->tp_print == NULL) {
PyObject *s;
if (flags & Py_PRINT_RAW)
s = PyObject_Str(op);
@@ -306,7 +306,7 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
Py_XDECREF(s);
}
else
- ret = (*Py_Type(op)->tp_print)(op, fp, flags);
+ ret = (*Py_TYPE(op)->tp_print)(op, fp, flags);
}
if (ret == 0) {
if (ferror(fp)) {
@@ -339,7 +339,7 @@ void _PyObject_Dump(PyObject* op)
"type : %s\n"
"refcount: %ld\n"
"address : %p\n",
- Py_Type(op)==NULL ? "NULL" : Py_Type(op)->tp_name,
+ Py_TYPE(op)==NULL ? "NULL" : Py_TYPE(op)->tp_name,
(long)op->ob_refcnt,
op);
}
@@ -358,12 +358,12 @@ PyObject_Repr(PyObject *v)
#endif
if (v == NULL)
return PyString_FromString("<NULL>");
- else if (Py_Type(v)->tp_repr == NULL)
+ else if (Py_TYPE(v)->tp_repr == NULL)
return PyString_FromFormat("<%s object at %p>",
- Py_Type(v)->tp_name, v);
+ Py_TYPE(v)->tp_name, v);
else {
PyObject *res;
- res = (*Py_Type(v)->tp_repr)(v);
+ res = (*Py_TYPE(v)->tp_repr)(v);
if (res == NULL)
return NULL;
#ifdef Py_USING_UNICODE
@@ -380,7 +380,7 @@ PyObject_Repr(PyObject *v)
if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__repr__ returned non-string (type %.200s)",
- Py_Type(res)->tp_name);
+ Py_TYPE(res)->tp_name);
Py_DECREF(res);
return NULL;
}
@@ -405,14 +405,14 @@ _PyObject_Str(PyObject *v)
return v;
}
#endif
- if (Py_Type(v)->tp_str == NULL)
+ if (Py_TYPE(v)->tp_str == NULL)
return PyObject_Repr(v);
/* It is possible for a type to have a tp_str representation that loops
infinitely. */
if (Py_EnterRecursiveCall(" while getting the str of an object"))
return NULL;
- res = (*Py_Type(v)->tp_str)(v);
+ res = (*Py_TYPE(v)->tp_str)(v);
Py_LeaveRecursiveCall();
if (res == NULL)
return NULL;
@@ -423,7 +423,7 @@ _PyObject_Str(PyObject *v)
if (!type_ok) {
PyErr_Format(PyExc_TypeError,
"__str__ returned non-string (type %.200s)",
- Py_Type(res)->tp_name);
+ Py_TYPE(res)->tp_name);
Py_DECREF(res);
return NULL;
}
@@ -497,8 +497,8 @@ PyObject_Unicode(PyObject *v)
res = v;
}
else {
- if (Py_Type(v)->tp_str != NULL)
- res = (*Py_Type(v)->tp_str)(v);
+ if (Py_TYPE(v)->tp_str != NULL)
+ res = (*Py_TYPE(v)->tp_str)(v);
else
res = PyObject_Repr(v);
}
@@ -1071,8 +1071,8 @@ PyObject_GetAttrString(PyObject *v, const char *name)
{
PyObject *w, *res;
- if (Py_Type(v)->tp_getattr != NULL)
- return (*Py_Type(v)->tp_getattr)(v, (char*)name);
+ if (Py_TYPE(v)->tp_getattr != NULL)
+ return (*Py_TYPE(v)->tp_getattr)(v, (char*)name);
w = PyString_InternFromString(name);
if (w == NULL)
return NULL;
@@ -1099,8 +1099,8 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
PyObject *s;
int res;
- if (Py_Type(v)->tp_setattr != NULL)
- return (*Py_Type(v)->tp_setattr)(v, (char*)name, w);
+ if (Py_TYPE(v)->tp_setattr != NULL)
+ return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w);
s = PyString_InternFromString(name);
if (s == NULL)
return -1;
@@ -1112,7 +1112,7 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
PyObject *
PyObject_GetAttr(PyObject *v, PyObject *name)
{
- PyTypeObject *tp = Py_Type(v);
+ PyTypeObject *tp = Py_TYPE(v);
if (!PyString_Check(name)) {
#ifdef Py_USING_UNICODE
@@ -1129,7 +1129,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
{
PyErr_Format(PyExc_TypeError,
"attribute name must be string, not '%.200s'",
- Py_Type(name)->tp_name);
+ Py_TYPE(name)->tp_name);
return NULL;
}
}
@@ -1158,7 +1158,7 @@ PyObject_HasAttr(PyObject *v, PyObject *name)
int
PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
{
- PyTypeObject *tp = Py_Type(v);
+ PyTypeObject *tp = Py_TYPE(v);
int err;
if (!PyString_Check(name)){
@@ -1176,7 +1176,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
{
PyErr_Format(PyExc_TypeError,
"attribute name must be string, not '%.200s'",
- Py_Type(name)->tp_name);
+ Py_TYPE(name)->tp_name);
return -1;
}
}
@@ -1218,7 +1218,7 @@ PyObject **
_PyObject_GetDictPtr(PyObject *obj)
{
Py_ssize_t dictoffset;
- PyTypeObject *tp = Py_Type(obj);
+ PyTypeObject *tp = Py_TYPE(obj);
if (!(tp->tp_flags & Py_TPFLAGS_HAVE_CLASS))
return NULL;
@@ -1253,7 +1253,7 @@ PyObject_SelfIter(PyObject *obj)
PyObject *
PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
{
- PyTypeObject *tp = Py_Type(obj);
+ PyTypeObject *tp = Py_TYPE(obj);
PyObject *descr = NULL;
PyObject *res = NULL;
descrgetfunc f;
@@ -1275,7 +1275,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
{
PyErr_Format(PyExc_TypeError,
"attribute name must be string, not '%.200s'",
- Py_Type(name)->tp_name);
+ Py_TYPE(name)->tp_name);
return NULL;
}
}
@@ -1355,7 +1355,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
}
if (f != NULL) {
- res = f(descr, obj, (PyObject *)Py_Type(obj));
+ res = f(descr, obj, (PyObject *)Py_TYPE(obj));
Py_DECREF(descr);
goto done;
}
@@ -1377,7 +1377,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
int
PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
{
- PyTypeObject *tp = Py_Type(obj);
+ PyTypeObject *tp = Py_TYPE(obj);
PyObject *descr;
descrsetfunc f;
PyObject **dictptr;
@@ -1398,7 +1398,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
{
PyErr_Format(PyExc_TypeError,
"attribute name must be string, not '%.200s'",
- Py_Type(name)->tp_name);
+ Py_TYPE(name)->tp_name);
return -1;
}
}
@@ -1692,7 +1692,7 @@ _dir_locals(void)
if (!PyList_Check(names)) {
PyErr_Format(PyExc_TypeError,
"dir(): expected keys() of locals to be a list, "
- "not '%.200s'", Py_Type(names)->tp_name);
+ "not '%.200s'", Py_TYPE(names)->tp_name);
Py_DECREF(names);
return NULL;
}
@@ -1827,7 +1827,7 @@ _dir_object(PyObject *obj)
if (!PyList_Check(result)) {
PyErr_Format(PyExc_TypeError,
"__dir__() must return a list, not %.200s",
- Py_Type(result)->tp_name);
+ Py_TYPE(result)->tp_name);
Py_DECREF(result);
result = NULL;
}
@@ -2006,7 +2006,7 @@ _Py_ForgetReference(register PyObject *op)
void
_Py_Dealloc(PyObject *op)
{
- destructor dealloc = Py_Type(op)->tp_dealloc;
+ destructor dealloc = Py_TYPE(op)->tp_dealloc;
_Py_ForgetReference(op);
(*dealloc)(op);
}
@@ -2037,7 +2037,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, Py_Type(op)->tp_name);
+ op->ob_refcnt, Py_TYPE(op)->tp_name);
}
PyObject *
@@ -2055,7 +2055,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 && Py_Type(op) != (PyTypeObject *) t)) {
+ (t != NULL && Py_TYPE(op) != (PyTypeObject *) t)) {
op = op->_ob_next;
if (op == &refchain)
return res;
@@ -2198,7 +2198,7 @@ _PyTrash_destroy_chain(void)
{
while (_PyTrash_delete_later) {
PyObject *op = _PyTrash_delete_later;
- destructor dealloc = Py_Type(op)->tp_dealloc;
+ destructor dealloc = Py_TYPE(op)->tp_dealloc;
_PyTrash_delete_later =
(PyObject*) _Py_AS_GC(op)->gc.gc_prev;
diff --git a/Objects/setobject.c b/Objects/setobject.c
index b049d09..bb49b67 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -561,7 +561,7 @@ set_dealloc(PySetObject *so)
if (num_free_sets < MAXFREESETS && PyAnySet_CheckExact(so))
free_sets[num_free_sets++] = so;
else
- Py_Type(so)->tp_free(so);
+ Py_TYPE(so)->tp_free(so);
Py_TRASHCAN_SAFE_END(so)
}
@@ -987,7 +987,7 @@ make_new_set(PyTypeObject *type, PyObject *iterable)
(type == &PySet_Type || type == &PyFrozenSet_Type)) {
so = free_sets[--num_free_sets];
assert (so != NULL && PyAnySet_CheckExact(so));
- Py_Type(so) = type;
+ Py_TYPE(so) = type;
_Py_NewReference((PyObject *)so);
EMPTY_TO_MINSIZE(so);
PyObject_GC_Track(so);
@@ -1113,8 +1113,8 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
memcpy(b->smalltable, tab, sizeof(tab));
}
- if (PyType_IsSubtype(Py_Type(a), &PyFrozenSet_Type) &&
- PyType_IsSubtype(Py_Type(b), &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;
@@ -1125,7 +1125,7 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
static PyObject *
set_copy(PySetObject *so)
{
- return make_new_set(Py_Type(so), (PyObject *)so);
+ return make_new_set(Py_TYPE(so), (PyObject *)so);
}
static PyObject *
@@ -1203,7 +1203,7 @@ set_intersection(PySetObject *so, PyObject *other)
if ((PyObject *)so == other)
return set_copy(so);
- result = (PySetObject *)make_new_set(Py_Type(so), NULL);
+ result = (PySetObject *)make_new_set(Py_TYPE(so), NULL);
if (result == NULL)
return NULL;
@@ -1457,7 +1457,7 @@ set_difference(PySetObject *so, PyObject *other)
return NULL;
}
- result = make_new_set(Py_Type(so), NULL);
+ result = make_new_set(Py_TYPE(so), NULL);
if (result == NULL)
return NULL;
@@ -1558,7 +1558,7 @@ set_symmetric_difference_update(PySetObject *so, PyObject *other)
Py_INCREF(other);
otherset = (PySetObject *)other;
} else {
- otherset = (PySetObject *)make_new_set(Py_Type(so), other);
+ otherset = (PySetObject *)make_new_set(Py_TYPE(so), other);
if (otherset == NULL)
return NULL;
}
@@ -1589,7 +1589,7 @@ set_symmetric_difference(PySetObject *so, PyObject *other)
PyObject *rv;
PySetObject *otherset;
- otherset = (PySetObject *)make_new_set(Py_Type(so), other);
+ otherset = (PySetObject *)make_new_set(Py_TYPE(so), other);
if (otherset == NULL)
return NULL;
rv = set_symmetric_difference_update(otherset, (PyObject *)so);
@@ -1856,7 +1856,7 @@ set_reduce(PySetObject *so)
dict = Py_None;
Py_INCREF(dict);
}
- result = PyTuple_Pack(3, Py_Type(so), args, dict);
+ result = PyTuple_Pack(3, Py_TYPE(so), args, dict);
done:
Py_XDECREF(args);
Py_XDECREF(keys);
@@ -1873,7 +1873,7 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
if (!PyAnySet_Check(self))
return -1;
- if (!PyArg_UnpackTuple(args, Py_Type(self)->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;
@@ -2168,7 +2168,7 @@ PySet_Size(PyObject *anyset)
int
PySet_Clear(PyObject *set)
{
- if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2188,7 +2188,7 @@ PySet_Contains(PyObject *anyset, PyObject *key)
int
PySet_Discard(PyObject *set, PyObject *key)
{
- if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2198,7 +2198,7 @@ PySet_Discard(PyObject *set, PyObject *key)
int
PySet_Add(PyObject *set, PyObject *key)
{
- if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2239,7 +2239,7 @@ _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash)
PyObject *
PySet_Pop(PyObject *set)
{
- if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
PyErr_BadInternalCall();
return NULL;
}
@@ -2249,7 +2249,7 @@ PySet_Pop(PyObject *set)
int
_PySet_Update(PyObject *set, PyObject *iterable)
{
- if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
+ if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
PyErr_BadInternalCall();
return -1;
}
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index d147bce..075418e 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -277,7 +277,7 @@ handling of normal slices.");
static PyObject *
slice_reduce(PySliceObject* self)
{
- return Py_BuildValue("O(OOO)", Py_Type(self), self->start, self->stop, self->step);
+ return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step);
}
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 2c8c989..21f59ac 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -421,7 +421,7 @@ PyObject *PyString_AsDecodedString(PyObject *str,
if (!PyString_Check(v)) {
PyErr_Format(PyExc_TypeError,
"decoder did not return a string object (type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
goto onError;
}
@@ -501,7 +501,7 @@ PyObject *PyString_AsEncodedString(PyObject *str,
if (!PyString_Check(v)) {
PyErr_Format(PyExc_TypeError,
"encoder did not return a string object (type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
goto onError;
}
@@ -521,7 +521,7 @@ string_dealloc(PyObject *op)
case SSTATE_INTERNED_MORTAL:
/* revive dead object temporarily for DelItem */
- Py_Refcnt(op) = 3;
+ Py_REFCNT(op) = 3;
if (PyDict_DelItem(interned, op) != 0)
Py_FatalError(
"deletion of interned string failed");
@@ -533,7 +533,7 @@ string_dealloc(PyObject *op)
default:
Py_FatalError("Inconsistent interned string state.");
}
- Py_Type(op)->tp_free(op);
+ Py_TYPE(op)->tp_free(op);
}
/* Unescape a backslash-escaped string. If unicode is non-zero,
@@ -719,7 +719,7 @@ PyString_Size(register PyObject *op)
{
if (!PyString_Check(op))
return string_getsize(op);
- return Py_Size(op);
+ return Py_SIZE(op);
}
/*const*/ char *
@@ -752,7 +752,7 @@ PyString_AsStringAndSize(register PyObject *obj,
{
PyErr_Format(PyExc_TypeError,
"expected string or Unicode object, "
- "%.200s found", Py_Type(obj)->tp_name);
+ "%.200s found", Py_TYPE(obj)->tp_name);
return -1;
}
}
@@ -807,7 +807,7 @@ string_print(PyStringObject *op, FILE *fp, int flags)
}
if (flags & Py_PRINT_RAW) {
char *data = op->ob_sval;
- Py_ssize_t size = Py_Size(op);
+ Py_ssize_t size = Py_SIZE(op);
Py_BEGIN_ALLOW_THREADS
while (size > INT_MAX) {
/* Very long strings cannot be written atomically.
@@ -830,11 +830,11 @@ string_print(PyStringObject *op, FILE *fp, int flags)
/* figure out which quote to use; single is preferred */
quote = '\'';
- if (memchr(op->ob_sval, '\'', Py_Size(op)) &&
- !memchr(op->ob_sval, '"', Py_Size(op)))
+ if (memchr(op->ob_sval, '\'', Py_SIZE(op)) &&
+ !memchr(op->ob_sval, '"', Py_SIZE(op)))
quote = '"';
- str_len = Py_Size(op);
+ str_len = Py_SIZE(op);
Py_BEGIN_ALLOW_THREADS
fputc(quote, fp);
for (i = 0; i < str_len; i++) {
@@ -864,9 +864,9 @@ PyObject *
PyString_Repr(PyObject *obj, int smartquotes)
{
register PyStringObject* op = (PyStringObject*) obj;
- size_t newsize = 2 + 4 * Py_Size(op);
+ size_t newsize = 2 + 4 * Py_SIZE(op);
PyObject *v;
- if (newsize > PY_SSIZE_T_MAX || newsize / 4 != Py_Size(op)) {
+ if (newsize > PY_SSIZE_T_MAX || newsize / 4 != Py_SIZE(op)) {
PyErr_SetString(PyExc_OverflowError,
"string is too large to make repr");
return NULL;
@@ -884,13 +884,13 @@ PyString_Repr(PyObject *obj, int smartquotes)
/* figure out which quote to use; single is preferred */
quote = '\'';
if (smartquotes &&
- memchr(op->ob_sval, '\'', Py_Size(op)) &&
- !memchr(op->ob_sval, '"', Py_Size(op)))
+ memchr(op->ob_sval, '\'', Py_SIZE(op)) &&
+ !memchr(op->ob_sval, '"', Py_SIZE(op)))
quote = '"';
p = PyString_AS_STRING(v);
*p++ = quote;
- for (i = 0; i < Py_Size(op); i++) {
+ for (i = 0; i < Py_SIZE(op); i++) {
/* There's at least enough room for a hex escape
and a closing quote. */
assert(newsize - (p - PyString_AS_STRING(v)) >= 5);
@@ -939,14 +939,14 @@ string_str(PyObject *s)
else {
/* Subtype -- return genuine string with the same value. */
PyStringObject *t = (PyStringObject *) s;
- return PyString_FromStringAndSize(t->ob_sval, Py_Size(t));
+ return PyString_FromStringAndSize(t->ob_sval, Py_SIZE(t));
}
}
static Py_ssize_t
string_length(PyStringObject *a)
{
- return Py_Size(a);
+ return Py_SIZE(a);
}
static PyObject *
@@ -961,21 +961,21 @@ string_concat(register PyStringObject *a, register PyObject *bb)
#endif
PyErr_Format(PyExc_TypeError,
"cannot concatenate 'str' and '%.200s' objects",
- Py_Type(bb)->tp_name);
+ Py_TYPE(bb)->tp_name);
return NULL;
}
#define b ((PyStringObject *)bb)
/* Optimize cases with empty left or right operand */
- if ((Py_Size(a) == 0 || Py_Size(b) == 0) &&
+ if ((Py_SIZE(a) == 0 || Py_SIZE(b) == 0) &&
PyString_CheckExact(a) && PyString_CheckExact(b)) {
- if (Py_Size(a) == 0) {
+ if (Py_SIZE(a) == 0) {
Py_INCREF(bb);
return bb;
}
Py_INCREF(a);
return (PyObject *)a;
}
- size = Py_Size(a) + Py_Size(b);
+ size = Py_SIZE(a) + Py_SIZE(b);
if (size < 0) {
PyErr_SetString(PyExc_OverflowError,
"strings are too large to concat");
@@ -989,8 +989,8 @@ string_concat(register PyStringObject *a, register PyObject *bb)
PyObject_INIT_VAR(op, &PyString_Type, size);
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
- Py_MEMCPY(op->ob_sval, a->ob_sval, Py_Size(a));
- Py_MEMCPY(op->ob_sval + Py_Size(a), b->ob_sval, Py_Size(b));
+ Py_MEMCPY(op->ob_sval, a->ob_sval, Py_SIZE(a));
+ Py_MEMCPY(op->ob_sval + Py_SIZE(a), b->ob_sval, Py_SIZE(b));
op->ob_sval[size] = '\0';
return (PyObject *) op;
#undef b
@@ -1009,13 +1009,13 @@ string_repeat(register PyStringObject *a, register Py_ssize_t n)
/* watch out for overflows: the size can overflow int,
* and the # of bytes needed can overflow size_t
*/
- size = Py_Size(a) * n;
- if (n && size / n != Py_Size(a)) {
+ size = Py_SIZE(a) * n;
+ if (n && size / n != Py_SIZE(a)) {
PyErr_SetString(PyExc_OverflowError,
"repeated string is too long");
return NULL;
}
- if (size == Py_Size(a) && PyString_CheckExact(a)) {
+ if (size == Py_SIZE(a) && PyString_CheckExact(a)) {
Py_INCREF(a);
return (PyObject *)a;
}
@@ -1033,14 +1033,14 @@ string_repeat(register PyStringObject *a, register Py_ssize_t n)
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
op->ob_sval[size] = '\0';
- if (Py_Size(a) == 1 && n > 0) {
+ if (Py_SIZE(a) == 1 && n > 0) {
memset(op->ob_sval, a->ob_sval[0] , n);
return (PyObject *) op;
}
i = 0;
if (i < size) {
- Py_MEMCPY(op->ob_sval, a->ob_sval, Py_Size(a));
- i = Py_Size(a);
+ Py_MEMCPY(op->ob_sval, a->ob_sval, Py_SIZE(a));
+ i = Py_SIZE(a);
}
while (i < size) {
j = (i <= size-i) ? i : size-i;
@@ -1061,9 +1061,9 @@ string_slice(register PyStringObject *a, register Py_ssize_t i,
i = 0;
if (j < 0)
j = 0; /* Avoid signed/unsigned bug in next line */
- if (j > Py_Size(a))
- j = Py_Size(a);
- if (i == 0 && j == Py_Size(a) && PyString_CheckExact(a)) {
+ if (j > Py_SIZE(a))
+ j = Py_SIZE(a);
+ if (i == 0 && j == Py_SIZE(a) && PyString_CheckExact(a)) {
/* It's the same as a */
Py_INCREF(a);
return (PyObject *)a;
@@ -1084,7 +1084,7 @@ string_contains(PyObject *str_obj, PyObject *sub_obj)
if (!PyString_Check(sub_obj)) {
PyErr_Format(PyExc_TypeError,
"'in <string>' requires string as left operand, "
- "not %.200s", Py_Type(sub_obj)->tp_name);
+ "not %.200s", Py_TYPE(sub_obj)->tp_name);
return -1;
}
}
@@ -1097,7 +1097,7 @@ string_item(PyStringObject *a, register Py_ssize_t i)
{
char pchar;
PyObject *v;
- if (i < 0 || i >= Py_Size(a)) {
+ if (i < 0 || i >= Py_SIZE(a)) {
PyErr_SetString(PyExc_IndexError, "string index out of range");
return NULL;
}
@@ -1140,16 +1140,16 @@ string_richcompare(PyStringObject *a, PyStringObject *b, int op)
if (op == Py_EQ) {
/* Supporting Py_NE here as well does not save
much time, since Py_NE is rarely used. */
- if (Py_Size(a) == Py_Size(b)
+ if (Py_SIZE(a) == Py_SIZE(b)
&& (a->ob_sval[0] == b->ob_sval[0]
- && memcmp(a->ob_sval, b->ob_sval, Py_Size(a)) == 0)) {
+ && memcmp(a->ob_sval, b->ob_sval, Py_SIZE(a)) == 0)) {
result = Py_True;
} else {
result = Py_False;
}
goto out;
}
- len_a = Py_Size(a); len_b = Py_Size(b);
+ len_a = Py_SIZE(a); len_b = Py_SIZE(b);
min_len = (len_a < len_b) ? len_a : len_b;
if (min_len > 0) {
c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval);
@@ -1181,9 +1181,9 @@ _PyString_Eq(PyObject *o1, PyObject *o2)
{
PyStringObject *a = (PyStringObject*) o1;
PyStringObject *b = (PyStringObject*) o2;
- return Py_Size(a) == Py_Size(b)
+ return Py_SIZE(a) == Py_SIZE(b)
&& *a->ob_sval == *b->ob_sval
- && memcmp(a->ob_sval, b->ob_sval, Py_Size(a)) == 0;
+ && memcmp(a->ob_sval, b->ob_sval, Py_SIZE(a)) == 0;
}
static long
@@ -1195,12 +1195,12 @@ string_hash(PyStringObject *a)
if (a->ob_shash != -1)
return a->ob_shash;
- len = Py_Size(a);
+ len = Py_SIZE(a);
p = (unsigned char *) a->ob_sval;
x = *p << 7;
while (--len >= 0)
x = (1000003*x) ^ *p++;
- x ^= Py_Size(a);
+ x ^= Py_SIZE(a);
if (x == -1)
x = -2;
a->ob_shash = x;
@@ -1264,7 +1264,7 @@ string_subscript(PyStringObject* self, PyObject* item)
else {
PyErr_Format(PyExc_TypeError,
"string indices must be integers, not %.200s",
- Py_Type(item)->tp_name);
+ Py_TYPE(item)->tp_name);
return NULL;
}
}
@@ -1278,7 +1278,7 @@ string_buffer_getreadbuf(PyStringObject *self, Py_ssize_t index, const void **pt
return -1;
}
*ptr = (void *)self->ob_sval;
- return Py_Size(self);
+ return Py_SIZE(self);
}
static Py_ssize_t
@@ -1293,7 +1293,7 @@ static Py_ssize_t
string_buffer_getsegcount(PyStringObject *self, Py_ssize_t *lenp)
{
if ( lenp )
- *lenp = Py_Size(self);
+ *lenp = Py_SIZE(self);
return 1;
}
@@ -1306,7 +1306,7 @@ string_buffer_getcharbuf(PyStringObject *self, Py_ssize_t index, const char **pt
return -1;
}
*ptr = self->ob_sval;
- return Py_Size(self);
+ return Py_SIZE(self);
}
static PySequenceMethods string_as_sequence = {
@@ -1395,7 +1395,7 @@ static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"};
count++; }
/* Always force the list to the expected size. */
-#define FIX_PREALLOC_SIZE(list) Py_Size(list) = count
+#define FIX_PREALLOC_SIZE(list) Py_SIZE(list) = count
#define SKIP_SPACE(s, i, len) { while (i<len && isspace(Py_CHARMASK(s[i]))) i++; }
#define SKIP_NONSPACE(s, i, len) { while (i<len && !isspace(Py_CHARMASK(s[i]))) i++; }
@@ -1841,7 +1841,7 @@ string_join(PyStringObject *self, PyObject *orig)
PyErr_Format(PyExc_TypeError,
"sequence item %zd: expected string,"
" %.80s found",
- i, Py_Type(item)->tp_name);
+ i, Py_TYPE(item)->tp_name);
Py_DECREF(seq);
return NULL;
}
@@ -3312,7 +3312,7 @@ string_encode(PyStringObject *self, PyObject *args)
PyErr_Format(PyExc_TypeError,
"encoder did not return a string/unicode object "
"(type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
return NULL;
}
@@ -3349,7 +3349,7 @@ string_decode(PyStringObject *self, PyObject *args)
PyErr_Format(PyExc_TypeError,
"decoder did not return a string/unicode object "
"(type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
return NULL;
}
@@ -3907,7 +3907,7 @@ string_splitlines(PyStringObject *self, PyObject *args)
static PyObject *
string_getnewargs(PyStringObject *v)
{
- return Py_BuildValue("(s#)", v->ob_sval, Py_Size(v));
+ return Py_BuildValue("(s#)", v->ob_sval, Py_SIZE(v));
}
@@ -4170,7 +4170,7 @@ _PyString_Resize(PyObject **pv, Py_ssize_t newsize)
register PyObject *v;
register PyStringObject *sv;
v = *pv;
- if (!PyString_Check(v) || Py_Refcnt(v) != 1 || newsize < 0 ||
+ if (!PyString_Check(v) || Py_REFCNT(v) != 1 || newsize < 0 ||
PyString_CHECK_INTERNED(v)) {
*pv = 0;
Py_DECREF(v);
@@ -4189,7 +4189,7 @@ _PyString_Resize(PyObject **pv, Py_ssize_t newsize)
}
_Py_NewReference(*pv);
sv = (PyStringObject *) *pv;
- Py_Size(sv) = newsize;
+ Py_SIZE(sv) = newsize;
sv->ob_sval[newsize] = '\0';
sv->ob_shash = -1; /* invalidate cached hash value */
return 0;
@@ -4237,7 +4237,7 @@ formatfloat(char *buf, size_t buflen, int flags,
x = PyFloat_AsDouble(v);
if (x == -1.0 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError, "float argument required, "
- "not %.200s", Py_Type(v)->tp_name);
+ "not %.200s", Py_TYPE(v)->tp_name);
return -1;
}
if (prec < 0)
@@ -4311,15 +4311,15 @@ _PyString_FormatLong(PyObject *val, int flags, int prec, int type,
switch (type) {
case 'd':
case 'u':
- result = Py_Type(val)->tp_str(val);
+ result = Py_TYPE(val)->tp_str(val);
break;
case 'o':
- result = Py_Type(val)->tp_as_number->nb_oct(val);
+ result = Py_TYPE(val)->tp_as_number->nb_oct(val);
break;
case 'x':
case 'X':
numnondigits = 2;
- result = Py_Type(val)->tp_as_number->nb_hex(val);
+ result = Py_TYPE(val)->tp_as_number->nb_hex(val);
break;
default:
assert(!"'type' not in [duoxX]");
@@ -4334,7 +4334,7 @@ _PyString_FormatLong(PyObject *val, int flags, int prec, int type,
}
/* To modify the string in-place, there can only be one reference. */
- if (Py_Refcnt(result) != 1) {
+ if (Py_REFCNT(result) != 1) {
PyErr_BadInternalCall();
return NULL;
}
@@ -4434,7 +4434,7 @@ formatint(char *buf, size_t buflen, int flags,
x = PyInt_AsLong(v);
if (x == -1 && PyErr_Occurred()) {
PyErr_Format(PyExc_TypeError, "int argument required, not %.200s",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
return -1;
}
if (x < 0 && type == 'u') {
@@ -4551,7 +4551,7 @@ PyString_Format(PyObject *format, PyObject *args)
arglen = -1;
argidx = -2;
}
- if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) &&
+ if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) &&
!PyObject_TypeCheck(args, &PyBaseString_Type))
dict = args;
while (--fmtcnt >= 0) {
@@ -5018,7 +5018,7 @@ PyString_InternInPlace(PyObject **p)
}
/* The two references in interned are not counted by refcnt.
The string deallocator will take care of this */
- Py_Refcnt(s) -= 2;
+ Py_REFCNT(s) -= 2;
PyString_CHECK_INTERNED(s) = SSTATE_INTERNED_MORTAL;
}
@@ -5085,12 +5085,12 @@ void _Py_ReleaseInternedStrings(void)
/* XXX Shouldn't happen */
break;
case SSTATE_INTERNED_IMMORTAL:
- Py_Refcnt(s) += 1;
- immortal_size += Py_Size(s);
+ Py_REFCNT(s) += 1;
+ immortal_size += Py_SIZE(s);
break;
case SSTATE_INTERNED_MORTAL:
- Py_Refcnt(s) += 2;
- mortal_size += Py_Size(s);
+ Py_REFCNT(s) += 2;
+ mortal_size += Py_SIZE(s);
break;
default:
Py_FatalError("Inconsistent interned string state.");
diff --git a/Objects/structseq.c b/Objects/structseq.c
index fb6b96d..8dcc2bc 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -13,17 +13,17 @@ static char unnamed_fields_key[] = "n_unnamed_fields";
They are only allowed for indices < n_visible_fields. */
char *PyStructSequence_UnnamedField = "unnamed field";
-#define VISIBLE_SIZE(op) Py_Size(op)
+#define VISIBLE_SIZE(op) Py_SIZE(op)
#define VISIBLE_SIZE_TP(tp) PyInt_AsLong( \
PyDict_GetItemString((tp)->tp_dict, visible_length_key))
#define REAL_SIZE_TP(tp) PyInt_AsLong( \
PyDict_GetItemString((tp)->tp_dict, real_length_key))
-#define REAL_SIZE(op) REAL_SIZE_TP(Py_Type(op))
+#define REAL_SIZE(op) REAL_SIZE_TP(Py_TYPE(op))
#define UNNAMED_FIELDS_TP(tp) PyInt_AsLong( \
PyDict_GetItemString((tp)->tp_dict, unnamed_fields_key))
-#define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_Type(op))
+#define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_TYPE(op))
PyObject *
@@ -32,7 +32,7 @@ PyStructSequence_New(PyTypeObject *type)
PyStructSequence *obj;
obj = PyObject_New(PyStructSequence, type);
- Py_Size(obj) = VISIBLE_SIZE_TP(type);
+ Py_SIZE(obj) = VISIBLE_SIZE_TP(type);
return (PyObject*) obj;
}
@@ -322,12 +322,12 @@ structseq_reduce(PyStructSequence* self)
}
for (; i < n_fields; i++) {
- char *n = Py_Type(self)->tp_members[i-n_unnamed_fields].name;
+ char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name;
PyDict_SetItemString(dict, n,
self->ob_item[i]);
}
- result = Py_BuildValue("(O(OO))", Py_Type(self), tup, dict);
+ result = Py_BuildValue("(O(OO))", Py_TYPE(self), tup, dict);
Py_DECREF(tup);
Py_DECREF(dict);
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index b1704f7..fba2139 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -49,8 +49,8 @@ PyTuple_New(register Py_ssize_t size)
#endif
/* Inline PyObject_InitVar */
#ifdef Py_TRACE_REFS
- Py_Size(op) = size;
- Py_Type(op) = &PyTuple_Type;
+ Py_SIZE(op) = size;
+ Py_TYPE(op) = &PyTuple_Type;
#endif
_Py_NewReference((PyObject *)op);
}
@@ -90,7 +90,7 @@ PyTuple_Size(register PyObject *op)
return -1;
}
else
- return Py_Size(op);
+ return Py_SIZE(op);
}
PyObject *
@@ -100,7 +100,7 @@ PyTuple_GetItem(register PyObject *op, register Py_ssize_t i)
PyErr_BadInternalCall();
return NULL;
}
- if (i < 0 || i >= Py_Size(op)) {
+ if (i < 0 || i >= Py_SIZE(op)) {
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
return NULL;
}
@@ -117,7 +117,7 @@ PyTuple_SetItem(register PyObject *op, register Py_ssize_t i, PyObject *newitem)
PyErr_BadInternalCall();
return -1;
}
- if (i < 0 || i >= Py_Size(op)) {
+ if (i < 0 || i >= Py_SIZE(op)) {
Py_XDECREF(newitem);
PyErr_SetString(PyExc_IndexError,
"tuple assignment index out of range");
@@ -160,7 +160,7 @@ static void
tupledealloc(register PyTupleObject *op)
{
register Py_ssize_t i;
- register Py_ssize_t len = Py_Size(op);
+ register Py_ssize_t len = Py_SIZE(op);
PyObject_GC_UnTrack(op);
Py_TRASHCAN_SAFE_BEGIN(op)
if (len > 0) {
@@ -170,7 +170,7 @@ tupledealloc(register PyTupleObject *op)
#if MAXSAVESIZE > 0
if (len < MAXSAVESIZE &&
num_free_tuples[len] < MAXSAVEDTUPLES &&
- Py_Type(op) == &PyTuple_Type)
+ Py_TYPE(op) == &PyTuple_Type)
{
op->ob_item[0] = (PyObject *) free_tuples[len];
num_free_tuples[len]++;
@@ -179,7 +179,7 @@ tupledealloc(register PyTupleObject *op)
}
#endif
}
- Py_Type(op)->tp_free((PyObject *)op);
+ Py_TYPE(op)->tp_free((PyObject *)op);
done:
Py_TRASHCAN_SAFE_END(op)
}
@@ -191,7 +191,7 @@ tupleprint(PyTupleObject *op, FILE *fp, int flags)
Py_BEGIN_ALLOW_THREADS
fprintf(fp, "(");
Py_END_ALLOW_THREADS
- for (i = 0; i < Py_Size(op); i++) {
+ for (i = 0; i < Py_SIZE(op); i++) {
if (i > 0) {
Py_BEGIN_ALLOW_THREADS
fprintf(fp, ", ");
@@ -200,7 +200,7 @@ tupleprint(PyTupleObject *op, FILE *fp, int flags)
if (PyObject_Print(op->ob_item[i], fp, 0) != 0)
return -1;
}
- i = Py_Size(op);
+ i = Py_SIZE(op);
Py_BEGIN_ALLOW_THREADS
if (i == 1)
fprintf(fp, ",");
@@ -216,7 +216,7 @@ tuplerepr(PyTupleObject *v)
PyObject *s, *temp;
PyObject *pieces, *result = NULL;
- n = Py_Size(v);
+ n = Py_SIZE(v);
if (n == 0)
return PyString_FromString("()");
@@ -289,7 +289,7 @@ static long
tuplehash(PyTupleObject *v)
{
register long x, y;
- register Py_ssize_t len = Py_Size(v);
+ register Py_ssize_t len = Py_SIZE(v);
register PyObject **p;
long mult = 1000003L;
x = 0x345678L;
@@ -311,7 +311,7 @@ tuplehash(PyTupleObject *v)
static Py_ssize_t
tuplelength(PyTupleObject *a)
{
- return Py_Size(a);
+ return Py_SIZE(a);
}
static int
@@ -320,7 +320,7 @@ tuplecontains(PyTupleObject *a, PyObject *el)
Py_ssize_t i;
int cmp;
- for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(a); ++i)
+ for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i),
Py_EQ);
return cmp;
@@ -329,7 +329,7 @@ tuplecontains(PyTupleObject *a, PyObject *el)
static PyObject *
tupleitem(register PyTupleObject *a, register Py_ssize_t i)
{
- if (i < 0 || i >= Py_Size(a)) {
+ if (i < 0 || i >= Py_SIZE(a)) {
PyErr_SetString(PyExc_IndexError, "tuple index out of range");
return NULL;
}
@@ -347,11 +347,11 @@ tupleslice(register PyTupleObject *a, register Py_ssize_t ilow,
Py_ssize_t len;
if (ilow < 0)
ilow = 0;
- if (ihigh > Py_Size(a))
- ihigh = Py_Size(a);
+ if (ihigh > Py_SIZE(a))
+ ihigh = Py_SIZE(a);
if (ihigh < ilow)
ihigh = ilow;
- if (ilow == 0 && ihigh == Py_Size(a) && PyTuple_CheckExact(a)) {
+ if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
Py_INCREF(a);
return (PyObject *)a;
}
@@ -389,11 +389,11 @@ tupleconcat(register PyTupleObject *a, register PyObject *bb)
if (!PyTuple_Check(bb)) {
PyErr_Format(PyExc_TypeError,
"can only concatenate tuple (not \"%.200s\") to tuple",
- Py_Type(bb)->tp_name);
+ Py_TYPE(bb)->tp_name);
return NULL;
}
#define b ((PyTupleObject *)bb)
- size = Py_Size(a) + Py_Size(b);
+ size = Py_SIZE(a) + Py_SIZE(b);
if (size < 0)
return PyErr_NoMemory();
np = (PyTupleObject *) PyTuple_New(size);
@@ -402,14 +402,14 @@ tupleconcat(register PyTupleObject *a, register PyObject *bb)
}
src = a->ob_item;
dest = np->ob_item;
- for (i = 0; i < Py_Size(a); i++) {
+ for (i = 0; i < Py_SIZE(a); i++) {
PyObject *v = src[i];
Py_INCREF(v);
dest[i] = v;
}
src = b->ob_item;
- dest = np->ob_item + Py_Size(a);
- for (i = 0; i < Py_Size(b); i++) {
+ dest = np->ob_item + Py_SIZE(a);
+ for (i = 0; i < Py_SIZE(b); i++) {
PyObject *v = src[i];
Py_INCREF(v);
dest[i] = v;
@@ -427,18 +427,18 @@ tuplerepeat(PyTupleObject *a, Py_ssize_t n)
PyObject **p, **items;
if (n < 0)
n = 0;
- if (Py_Size(a) == 0 || n == 1) {
+ if (Py_SIZE(a) == 0 || n == 1) {
if (PyTuple_CheckExact(a)) {
/* Since tuples are immutable, we can return a shared
copy in this case */
Py_INCREF(a);
return (PyObject *)a;
}
- if (Py_Size(a) == 0)
+ if (Py_SIZE(a) == 0)
return PyTuple_New(0);
}
- size = Py_Size(a) * n;
- if (size/Py_Size(a) != n)
+ size = Py_SIZE(a) * n;
+ if (size/Py_SIZE(a) != n)
return PyErr_NoMemory();
np = (PyTupleObject *) PyTuple_New(size);
if (np == NULL)
@@ -446,7 +446,7 @@ tuplerepeat(PyTupleObject *a, Py_ssize_t n)
p = np->ob_item;
items = a->ob_item;
for (i = 0; i < n; i++) {
- for (j = 0; j < Py_Size(a); j++) {
+ for (j = 0; j < Py_SIZE(a); j++) {
*p = items[j];
Py_INCREF(*p);
p++;
@@ -460,7 +460,7 @@ tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
{
Py_ssize_t i;
- for (i = Py_Size(o); --i >= 0; )
+ for (i = Py_SIZE(o); --i >= 0; )
Py_VISIT(o->ob_item[i]);
return 0;
}
@@ -480,8 +480,8 @@ tuplerichcompare(PyObject *v, PyObject *w, int op)
vt = (PyTupleObject *)v;
wt = (PyTupleObject *)w;
- vlen = Py_Size(vt);
- wlen = Py_Size(wt);
+ vlen = Py_SIZE(vt);
+ wlen = Py_SIZE(wt);
/* Note: the corresponding code for lists has an "early out" test
* here when op is EQ or NE and the lengths differ. That pays there,
@@ -649,7 +649,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
else {
PyErr_Format(PyExc_TypeError,
"tuple indices must be integers, not %.200s",
- Py_Type(item)->tp_name);
+ Py_TYPE(item)->tp_name);
return NULL;
}
}
@@ -657,7 +657,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
static PyObject *
tuple_getnewargs(PyTupleObject *v)
{
- return Py_BuildValue("(N)", tupleslice(v, 0, Py_Size(v)));
+ return Py_BuildValue("(N)", tupleslice(v, 0, Py_SIZE(v)));
}
@@ -733,14 +733,14 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
Py_ssize_t oldsize;
v = (PyTupleObject *) *pv;
- if (v == NULL || Py_Type(v) != &PyTuple_Type ||
- (Py_Size(v) != 0 && Py_Refcnt(v) != 1)) {
+ if (v == NULL || Py_TYPE(v) != &PyTuple_Type ||
+ (Py_SIZE(v) != 0 && Py_REFCNT(v) != 1)) {
*pv = 0;
Py_XDECREF(v);
PyErr_BadInternalCall();
return -1;
}
- oldsize = Py_Size(v);
+ oldsize = Py_SIZE(v);
if (oldsize == newsize)
return 0;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 1a221c8..e418137 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -57,7 +57,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
if (!PyString_Check(value)) {
PyErr_Format(PyExc_TypeError,
"can only assign string to %s.__name__, not '%s'",
- type->tp_name, Py_Type(value)->tp_name);
+ type->tp_name, Py_TYPE(value)->tp_name);
return -1;
}
if (strlen(PyString_AS_STRING(value))
@@ -203,7 +203,7 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
if (!PyTuple_Check(value)) {
PyErr_Format(PyExc_TypeError,
"can only assign tuple to %s.__bases__, not %s",
- type->tp_name, Py_Type(value)->tp_name);
+ type->tp_name, Py_TYPE(value)->tp_name);
return -1;
}
if (PyTuple_GET_SIZE(value) == 0) {
@@ -218,7 +218,7 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
PyErr_Format(
PyExc_TypeError,
"%s.__bases__ must be tuple of old- or new-style classes, not '%s'",
- type->tp_name, Py_Type(ob)->tp_name);
+ type->tp_name, Py_TYPE(ob)->tp_name);
return -1;
}
if (PyType_Check(ob)) {
@@ -343,8 +343,8 @@ type_get_doc(PyTypeObject *type, void *context)
result = Py_None;
Py_INCREF(result);
}
- else if (Py_Type(result)->tp_descr_get) {
- result = Py_Type(result)->tp_descr_get(result, NULL,
+ else if (Py_TYPE(result)->tp_descr_get) {
+ result = Py_TYPE(result)->tp_descr_get(result, NULL,
(PyObject *)type);
}
else {
@@ -488,7 +488,7 @@ traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg)
Py_ssize_t i, n;
PyMemberDef *mp;
- n = Py_Size(type);
+ n = Py_SIZE(type);
mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
for (i = 0; i < n; i++, mp++) {
if (mp->type == T_OBJECT_EX) {
@@ -512,10 +512,10 @@ subtype_traverse(PyObject *self, visitproc visit, void *arg)
/* Find the nearest base with a different tp_traverse,
and traverse slots while we're at it */
- type = Py_Type(self);
+ type = Py_TYPE(self);
base = type;
while ((basetraverse = base->tp_traverse) == subtype_traverse) {
- if (Py_Size(base)) {
+ if (Py_SIZE(base)) {
int err = traverse_slots(base, self, visit, arg);
if (err)
return err;
@@ -547,7 +547,7 @@ clear_slots(PyTypeObject *type, PyObject *self)
Py_ssize_t i, n;
PyMemberDef *mp;
- n = Py_Size(type);
+ n = Py_SIZE(type);
mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type);
for (i = 0; i < n; i++, mp++) {
if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) {
@@ -569,10 +569,10 @@ subtype_clear(PyObject *self)
/* Find the nearest base with a different tp_clear
and clear slots while we're at it */
- type = Py_Type(self);
+ type = Py_TYPE(self);
base = type;
while ((baseclear = base->tp_clear) == subtype_clear) {
- if (Py_Size(base))
+ if (Py_SIZE(base))
clear_slots(base, self);
base = base->tp_base;
assert(base);
@@ -593,7 +593,7 @@ subtype_dealloc(PyObject *self)
destructor basedealloc;
/* Extract the type; we expect it to be a heap type */
- type = Py_Type(self);
+ type = Py_TYPE(self);
assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
/* Test whether the type has GC exactly once */
@@ -615,7 +615,7 @@ subtype_dealloc(PyObject *self)
/* Find the nearest base with a different tp_dealloc */
base = type;
while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
- assert(Py_Size(base) == 0);
+ assert(Py_SIZE(base) == 0);
base = base->tp_base;
assert(base);
}
@@ -683,7 +683,7 @@ subtype_dealloc(PyObject *self)
/* Clear slots up to the nearest base with a different tp_dealloc */
base = type;
while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
- if (Py_Size(base))
+ if (Py_SIZE(base))
clear_slots(base, self);
base = base->tp_base;
assert(base);
@@ -877,13 +877,13 @@ lookup_maybe(PyObject *self, char *attrstr, PyObject **attrobj)
if (*attrobj == NULL)
return NULL;
}
- res = _PyType_Lookup(Py_Type(self), *attrobj);
+ res = _PyType_Lookup(Py_TYPE(self), *attrobj);
if (res != NULL) {
descrgetfunc f;
- if ((f = Py_Type(res)->tp_descr_get) == NULL)
+ if ((f = Py_TYPE(res)->tp_descr_get) == NULL)
Py_INCREF(res);
else
- res = f(res, self, (PyObject *)(Py_Type(self)));
+ res = f(res, self, (PyObject *)(Py_TYPE(self)));
}
return res;
}
@@ -1301,7 +1301,7 @@ mro_internal(PyTypeObject *type)
PyObject *mro, *result, *tuple;
int checkit = 0;
- if (Py_Type(type) == &PyType_Type) {
+ if (Py_TYPE(type) == &PyType_Type) {
result = mro_implementation(type);
}
else {
@@ -1336,7 +1336,7 @@ mro_internal(PyTypeObject *type)
else if (!PyType_Check(cls)) {
PyErr_Format(PyExc_TypeError,
"mro() returned a non-class ('%.500s')",
- Py_Type(cls)->tp_name);
+ Py_TYPE(cls)->tp_name);
Py_DECREF(tuple);
return -1;
}
@@ -1565,7 +1565,7 @@ subtype_setdict(PyObject *obj, PyObject *value, void *context)
if (value != NULL && !PyDict_Check(value)) {
PyErr_Format(PyExc_TypeError,
"__dict__ must be set to a dictionary, "
- "not a '%.200s'", Py_Type(value)->tp_name);
+ "not a '%.200s'", Py_TYPE(value)->tp_name);
return -1;
}
dict = *dictptr;
@@ -1581,16 +1581,16 @@ subtype_getweakref(PyObject *obj, void *context)
PyObject **weaklistptr;
PyObject *result;
- if (Py_Type(obj)->tp_weaklistoffset == 0) {
+ if (Py_TYPE(obj)->tp_weaklistoffset == 0) {
PyErr_SetString(PyExc_AttributeError,
"This object has no __weakref__");
return NULL;
}
- assert(Py_Type(obj)->tp_weaklistoffset > 0);
- assert(Py_Type(obj)->tp_weaklistoffset + sizeof(PyObject *) <=
- (size_t)(Py_Type(obj)->tp_basicsize));
+ assert(Py_TYPE(obj)->tp_weaklistoffset > 0);
+ assert(Py_TYPE(obj)->tp_weaklistoffset + sizeof(PyObject *) <=
+ (size_t)(Py_TYPE(obj)->tp_basicsize));
weaklistptr = (PyObject **)
- ((char *)obj + Py_Type(obj)->tp_weaklistoffset);
+ ((char *)obj + Py_TYPE(obj)->tp_weaklistoffset);
if (*weaklistptr == NULL)
result = Py_None;
else
@@ -1630,7 +1630,7 @@ valid_identifier(PyObject *s)
if (!PyString_Check(s)) {
PyErr_Format(PyExc_TypeError,
"__slots__ items must be strings, not '%.200s'",
- Py_Type(s)->tp_name);
+ Py_TYPE(s)->tp_name);
return 0;
}
p = (unsigned char *) PyString_AS_STRING(s);
@@ -1740,8 +1740,8 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) {
PyObject *x = PyTuple_GET_ITEM(args, 0);
- Py_INCREF(Py_Type(x));
- return (PyObject *) Py_Type(x);
+ Py_INCREF(Py_TYPE(x));
+ return (PyObject *) Py_TYPE(x);
}
/* SF bug 475327 -- if that didn't trigger, we need 3
@@ -2176,7 +2176,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
static PyObject *
type_getattro(PyTypeObject *type, PyObject *name)
{
- PyTypeObject *metatype = Py_Type(type);
+ PyTypeObject *metatype = Py_TYPE(type);
PyObject *meta_attribute, *attribute;
descrgetfunc meta_get;
@@ -2193,7 +2193,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
meta_attribute = _PyType_Lookup(metatype, name);
if (meta_attribute != NULL) {
- meta_get = Py_Type(meta_attribute)->tp_descr_get;
+ meta_get = Py_TYPE(meta_attribute)->tp_descr_get;
if (meta_get != NULL && PyDescr_IsData(meta_attribute)) {
/* Data descriptors implement tp_descr_set to intercept
@@ -2211,7 +2211,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
attribute = _PyType_Lookup(type, name);
if (attribute != NULL) {
/* Implement descriptor functionality, if any */
- descrgetfunc local_get = Py_Type(attribute)->tp_descr_get;
+ descrgetfunc local_get = Py_TYPE(attribute)->tp_descr_get;
Py_XDECREF(meta_attribute);
@@ -2289,7 +2289,7 @@ type_dealloc(PyTypeObject *type)
PyObject_Free((char *)type->tp_doc);
Py_XDECREF(et->ht_name);
Py_XDECREF(et->ht_slots);
- Py_Type(type)->tp_free((PyObject *)type);
+ Py_TYPE(type)->tp_free((PyObject *)type);
}
static PyObject *
@@ -2499,7 +2499,7 @@ object_init(PyObject *self, PyObject *args, PyObject *kwds)
{
int err = 0;
if (excess_args(args, kwds)) {
- PyTypeObject *type = Py_Type(self);
+ PyTypeObject *type = Py_TYPE(self);
if (type->tp_init != object_init &&
type->tp_new != object_new)
{
@@ -2546,7 +2546,7 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static void
object_dealloc(PyObject *self)
{
- Py_Type(self)->tp_free(self);
+ Py_TYPE(self)->tp_free(self);
}
static PyObject *
@@ -2555,7 +2555,7 @@ object_repr(PyObject *self)
PyTypeObject *type;
PyObject *mod, *name, *rtn;
- type = Py_Type(self);
+ type = Py_TYPE(self);
mod = type_module(type, NULL);
if (mod == NULL)
PyErr_Clear();
@@ -2584,7 +2584,7 @@ object_str(PyObject *self)
{
unaryfunc f;
- f = Py_Type(self)->tp_repr;
+ f = Py_TYPE(self)->tp_repr;
if (f == NULL)
f = object_repr;
return f(self);
@@ -2593,8 +2593,8 @@ object_str(PyObject *self)
static PyObject *
object_get_class(PyObject *self, void *closure)
{
- Py_INCREF(Py_Type(self));
- return (PyObject *)(Py_Type(self));
+ Py_INCREF(Py_TYPE(self));
+ return (PyObject *)(Py_TYPE(self));
}
static int
@@ -2679,7 +2679,7 @@ compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr)
static int
object_set_class(PyObject *self, PyObject *value, void *closure)
{
- PyTypeObject *oldto = Py_Type(self);
+ PyTypeObject *oldto = Py_TYPE(self);
PyTypeObject *newto;
if (value == NULL) {
@@ -2690,7 +2690,7 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
if (!PyType_Check(value)) {
PyErr_Format(PyExc_TypeError,
"__class__ must be set to new-style class, not '%s' object",
- Py_Type(value)->tp_name);
+ Py_TYPE(value)->tp_name);
return -1;
}
newto = (PyTypeObject *)value;
@@ -2703,7 +2703,7 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
}
if (compatible_for_assignment(newto, oldto, "__class__")) {
Py_INCREF(newto);
- Py_Type(self) = newto;
+ Py_TYPE(self) = newto;
Py_DECREF(oldto);
return 0;
}
@@ -2799,7 +2799,7 @@ reduce_2(PyObject *obj)
if (args != NULL && !PyTuple_Check(args)) {
PyErr_Format(PyExc_TypeError,
"__getnewargs__ should return a tuple, "
- "not '%.200s'", Py_Type(args)->tp_name);
+ "not '%.200s'", Py_TYPE(args)->tp_name);
goto end;
}
}
@@ -3481,8 +3481,8 @@ PyType_Ready(PyTypeObject *type)
NULL when type is &PyBaseObject_Type, and we know its ob_type is
not NULL (it's initialized to &PyType_Type). But coverity doesn't
know that. */
- if (Py_Type(type) == NULL && base != NULL)
- Py_Type(type) = Py_Type(base);
+ if (Py_TYPE(type) == NULL && base != NULL)
+ Py_TYPE(type) = Py_TYPE(base);
/* Initialize tp_bases */
bases = type->tp_bases;
@@ -3854,7 +3854,7 @@ getindex(PyObject *self, PyObject *arg)
if (i == -1 && PyErr_Occurred())
return -1;
if (i < 0) {
- PySequenceMethods *sq = Py_Type(self)->tp_as_sequence;
+ PySequenceMethods *sq = Py_TYPE(self)->tp_as_sequence;
if (sq && sq->sq_length) {
Py_ssize_t n = (*sq->sq_length)(self);
if (n < 0)
@@ -4030,14 +4030,14 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
if (!check_num_args(args, 1))
return NULL;
other = PyTuple_GET_ITEM(args, 0);
- if (Py_Type(other)->tp_compare != func &&
- !PyType_IsSubtype(Py_Type(other), Py_Type(self))) {
+ if (Py_TYPE(other)->tp_compare != func &&
+ !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) {
PyErr_Format(
PyExc_TypeError,
"%s.__cmp__(x,y) requires y to be a '%s', not a '%s'",
- Py_Type(self)->tp_name,
- Py_Type(self)->tp_name,
- Py_Type(other)->tp_name);
+ Py_TYPE(self)->tp_name,
+ Py_TYPE(self)->tp_name,
+ Py_TYPE(other)->tp_name);
return NULL;
}
res = (*func)(self, other);
@@ -4051,7 +4051,7 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
static int
hackcheck(PyObject *self, setattrofunc func, char *what)
{
- PyTypeObject *type = Py_Type(self);
+ PyTypeObject *type = Py_TYPE(self);
while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)
type = type->tp_base;
/* If type is NULL now, this is a really weird type.
@@ -4251,7 +4251,7 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
PyErr_Format(PyExc_TypeError,
"%s.__new__(X): X is not a type object (%s)",
type->tp_name,
- Py_Type(arg0)->tp_name);
+ Py_TYPE(arg0)->tp_name);
return NULL;
}
subtype = (PyTypeObject *)arg0;
@@ -4342,14 +4342,14 @@ method_is_overloaded(PyObject *left, PyObject *right, char *name)
PyObject *a, *b;
int ok;
- b = PyObject_GetAttrString((PyObject *)(Py_Type(right)), name);
+ b = PyObject_GetAttrString((PyObject *)(Py_TYPE(right)), name);
if (b == NULL) {
PyErr_Clear();
/* If right doesn't have it, it's not overloaded */
return 0;
}
- a = PyObject_GetAttrString((PyObject *)(Py_Type(left)), name);
+ a = PyObject_GetAttrString((PyObject *)(Py_TYPE(left)), name);
if (a == NULL) {
PyErr_Clear();
Py_DECREF(b);
@@ -4374,14 +4374,14 @@ static PyObject * \
FUNCNAME(PyObject *self, PyObject *other) \
{ \
static PyObject *cache_str, *rcache_str; \
- int do_other = Py_Type(self) != Py_Type(other) && \
- Py_Type(other)->tp_as_number != NULL && \
- Py_Type(other)->tp_as_number->SLOTNAME == TESTFUNC; \
- if (Py_Type(self)->tp_as_number != NULL && \
- Py_Type(self)->tp_as_number->SLOTNAME == TESTFUNC) { \
+ int do_other = Py_TYPE(self) != Py_TYPE(other) && \
+ Py_TYPE(other)->tp_as_number != NULL && \
+ Py_TYPE(other)->tp_as_number->SLOTNAME == TESTFUNC; \
+ if (Py_TYPE(self)->tp_as_number != NULL && \
+ Py_TYPE(self)->tp_as_number->SLOTNAME == TESTFUNC) { \
PyObject *r; \
if (do_other && \
- PyType_IsSubtype(Py_Type(other), Py_Type(self)) && \
+ PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)) && \
method_is_overloaded(self, other, ROPSTR)) { \
r = call_maybe( \
other, ROPSTR, &rcache_str, "(O)", self); \
@@ -4393,7 +4393,7 @@ FUNCNAME(PyObject *self, PyObject *other) \
r = call_maybe( \
self, OPSTR, &cache_str, "(O)", other); \
if (r != Py_NotImplemented || \
- Py_Type(other) == Py_Type(self)) \
+ Py_TYPE(other) == Py_TYPE(self)) \
return r; \
Py_DECREF(r); \
} \
@@ -4451,12 +4451,12 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
if (getitem_str == NULL)
return NULL;
}
- func = _PyType_Lookup(Py_Type(self), getitem_str);
+ func = _PyType_Lookup(Py_TYPE(self), getitem_str);
if (func != NULL) {
- if ((f = Py_Type(func)->tp_descr_get) == NULL)
+ if ((f = Py_TYPE(func)->tp_descr_get) == NULL)
Py_INCREF(func);
else {
- func = f(func, self, (PyObject *)(Py_Type(self)));
+ func = f(func, self, (PyObject *)(Py_TYPE(self)));
if (func == NULL) {
return NULL;
}
@@ -4595,8 +4595,8 @@ slot_nb_power(PyObject *self, PyObject *other, PyObject *modulus)
/* Three-arg power doesn't use __rpow__. But ternary_op
can call this when the second argument's type uses
slot_nb_power, so check before calling self.__pow__. */
- if (Py_Type(self)->tp_as_number != NULL &&
- Py_Type(self)->tp_as_number->nb_power == slot_nb_power) {
+ if (Py_TYPE(self)->tp_as_number != NULL &&
+ Py_TYPE(self)->tp_as_number->nb_power == slot_nb_power) {
return call_method(self, "__pow__", &pow_str,
"(OO)", other, modulus);
}
@@ -4786,12 +4786,12 @@ _PyObject_SlotCompare(PyObject *self, PyObject *other)
{
int c;
- if (Py_Type(self)->tp_compare == _PyObject_SlotCompare) {
+ if (Py_TYPE(self)->tp_compare == _PyObject_SlotCompare) {
c = half_compare(self, other);
if (c <= 1)
return c;
}
- if (Py_Type(other)->tp_compare == _PyObject_SlotCompare) {
+ if (Py_TYPE(other)->tp_compare == _PyObject_SlotCompare) {
c = half_compare(other, self);
if (c < -1)
return -2;
@@ -4816,7 +4816,7 @@ slot_tp_repr(PyObject *self)
}
PyErr_Clear();
return PyString_FromFormat("<%s object at %p>",
- Py_Type(self)->tp_name, self);
+ Py_TYPE(self)->tp_name, self);
}
static PyObject *
@@ -4916,7 +4916,7 @@ slot_tp_getattro(PyObject *self, PyObject *name)
static PyObject *
slot_tp_getattr_hook(PyObject *self, PyObject *name)
{
- PyTypeObject *tp = Py_Type(self);
+ PyTypeObject *tp = Py_TYPE(self);
PyObject *getattr, *getattribute, *res;
static PyObject *getattribute_str = NULL;
static PyObject *getattr_str = NULL;
@@ -4940,7 +4940,7 @@ slot_tp_getattr_hook(PyObject *self, PyObject *name)
}
getattribute = _PyType_Lookup(tp, getattribute_str);
if (getattribute == NULL ||
- (Py_Type(getattribute) == &PyWrapperDescr_Type &&
+ (Py_TYPE(getattribute) == &PyWrapperDescr_Type &&
((PyWrapperDescrObject *)getattribute)->d_wrapped ==
(void *)PyObject_GenericGetAttr))
res = PyObject_GenericGetAttr(self, name);
@@ -4999,13 +4999,13 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op)
{
PyObject *res;
- if (Py_Type(self)->tp_richcompare == slot_tp_richcompare) {
+ if (Py_TYPE(self)->tp_richcompare == slot_tp_richcompare) {
res = half_richcompare(self, other, op);
if (res != Py_NotImplemented)
return res;
Py_DECREF(res);
}
- if (Py_Type(other)->tp_richcompare == slot_tp_richcompare) {
+ if (Py_TYPE(other)->tp_richcompare == slot_tp_richcompare) {
res = half_richcompare(other, self, _Py_SwappedOp[op]);
if (res != Py_NotImplemented) {
return res;
@@ -5038,7 +5038,7 @@ slot_tp_iter(PyObject *self)
if (func == NULL) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not iterable",
- Py_Type(self)->tp_name);
+ Py_TYPE(self)->tp_name);
return NULL;
}
Py_DECREF(func);
@@ -5055,7 +5055,7 @@ slot_tp_iternext(PyObject *self)
static PyObject *
slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{
- PyTypeObject *tp = Py_Type(self);
+ PyTypeObject *tp = Py_TYPE(self);
PyObject *get;
static PyObject *get_str = NULL;
@@ -5113,7 +5113,7 @@ slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds)
if (res != Py_None) {
PyErr_Format(PyExc_TypeError,
"__init__() should return None, not '%.200s'",
- Py_Type(res)->tp_name);
+ Py_TYPE(res)->tp_name);
Py_DECREF(res);
return -1;
}
@@ -5198,7 +5198,7 @@ slot_tp_del(PyObject *self)
_Py_NewReference(self);
self->ob_refcnt = refcnt;
}
- assert(!PyType_IS_GC(Py_Type(self)) ||
+ assert(!PyType_IS_GC(Py_TYPE(self)) ||
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
* we need to undo that. */
@@ -5210,8 +5210,8 @@ slot_tp_del(PyObject *self)
* undone.
*/
#ifdef COUNT_ALLOCS
- --Py_Type(self)->tp_frees;
- --Py_Type(self)->tp_allocs;
+ --Py_TYPE(self)->tp_frees;
+ --Py_TYPE(self)->tp_allocs;
#endif
}
@@ -5573,7 +5573,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
descr = _PyType_Lookup(type, p->name_strobj);
if (descr == NULL)
continue;
- if (Py_Type(descr) == &PyWrapperDescr_Type) {
+ if (Py_TYPE(descr) == &PyWrapperDescr_Type) {
void **tptr = resolve_slotdups(type, p->name_strobj);
if (tptr == NULL || tptr == ptr)
generic = p->function;
@@ -5588,7 +5588,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
use_generic = 1;
}
}
- else if (Py_Type(descr) == &PyCFunction_Type &&
+ else if (Py_TYPE(descr) == &PyCFunction_Type &&
PyCFunction_GET_FUNCTION(descr) ==
(PyCFunction)tp_new_wrapper &&
strcmp(p->name, "__new__") == 0)
@@ -5859,7 +5859,7 @@ super_dealloc(PyObject *self)
Py_XDECREF(su->obj);
Py_XDECREF(su->type);
Py_XDECREF(su->obj_type);
- Py_Type(self)->tp_free(self);
+ Py_TYPE(self)->tp_free(self);
}
static PyObject *
@@ -5924,7 +5924,7 @@ super_getattro(PyObject *self, PyObject *name)
res = PyDict_GetItem(dict, name);
if (res != NULL) {
Py_INCREF(res);
- f = Py_Type(res)->tp_descr_get;
+ f = Py_TYPE(res)->tp_descr_get;
if (f != NULL) {
tmp = f(res,
/* Only pass 'obj' param if
@@ -5960,7 +5960,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
the normal case; the return value is obj.__class__.
But... when obj is an instance, we want to allow for the case where
- Py_Type(obj) is not a subclass of type, but obj.__class__ is!
+ Py_TYPE(obj) is not a subclass of type, but obj.__class__ is!
This will allow using super() with a proxy for obj.
*/
@@ -5971,9 +5971,9 @@ supercheck(PyTypeObject *type, PyObject *obj)
}
/* Normal case */
- if (PyType_IsSubtype(Py_Type(obj), type)) {
- Py_INCREF(Py_Type(obj));
- return Py_Type(obj);
+ if (PyType_IsSubtype(Py_TYPE(obj), type)) {
+ Py_INCREF(Py_TYPE(obj));
+ return Py_TYPE(obj);
}
else {
/* Try the slow way */
@@ -5990,7 +5990,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
if (class_attr != NULL &&
PyType_Check(class_attr) &&
- (PyTypeObject *)class_attr != Py_Type(obj))
+ (PyTypeObject *)class_attr != Py_TYPE(obj))
{
int ok = PyType_IsSubtype(
(PyTypeObject *)class_attr, type);
@@ -6021,10 +6021,10 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
Py_INCREF(self);
return self;
}
- if (Py_Type(su) != &PySuper_Type)
+ if (Py_TYPE(su) != &PySuper_Type)
/* If su is an instance of a (strict) subclass of super,
call its type */
- return PyObject_CallFunctionObjArgs((PyObject *)Py_Type(su),
+ return PyObject_CallFunctionObjArgs((PyObject *)Py_TYPE(su),
su->type, obj, NULL);
else {
/* Inline the common case */
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 18b861b..4241fe9 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -312,7 +312,7 @@ void unicode_dealloc(register PyUnicodeObject *unicode)
else {
PyMem_DEL(unicode->str);
Py_XDECREF(unicode->defenc);
- Py_Type(unicode)->tp_free((PyObject *)unicode);
+ Py_TYPE(unicode)->tp_free((PyObject *)unicode);
}
}
@@ -326,7 +326,7 @@ int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length)
return -1;
}
v = (PyUnicodeObject *)*unicode;
- if (v == NULL || !PyUnicode_Check(v) || Py_Refcnt(v) != 1 || length < 0) {
+ if (v == NULL || !PyUnicode_Check(v) || Py_REFCNT(v) != 1 || length < 0) {
PyErr_BadInternalCall();
return -1;
}
@@ -554,7 +554,7 @@ PyObject *PyUnicode_FromEncodedObject(register PyObject *obj,
PyErr_Format(PyExc_TypeError,
"coercing to Unicode: need string or buffer, "
"%.80s found",
- Py_Type(obj)->tp_name);
+ Py_TYPE(obj)->tp_name);
goto onError;
}
@@ -604,7 +604,7 @@ PyObject *PyUnicode_Decode(const char *s,
if (!PyUnicode_Check(unicode)) {
PyErr_Format(PyExc_TypeError,
"decoder did not return an unicode object (type=%.400s)",
- Py_Type(unicode)->tp_name);
+ Py_TYPE(unicode)->tp_name);
Py_DECREF(unicode);
goto onError;
}
@@ -714,7 +714,7 @@ PyObject *PyUnicode_AsEncodedString(PyObject *unicode,
if (!PyString_Check(v)) {
PyErr_Format(PyExc_TypeError,
"encoder did not return a string object (type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
goto onError;
}
@@ -3789,7 +3789,7 @@ charmapencode_result charmapencode_output(Py_UNICODE c, PyObject *mapping,
char *outstart;
Py_ssize_t outsize = PyString_GET_SIZE(*outobj);
- if (Py_Type(mapping) == &EncodingMapType) {
+ if (Py_TYPE(mapping) == &EncodingMapType) {
int res = encoding_map_lookup(c, mapping);
Py_ssize_t requiredsize = *outpos+1;
if (res == -1)
@@ -3861,7 +3861,7 @@ int charmap_encoding_error(
/* find all unencodable characters */
while (collendpos < size) {
PyObject *rep;
- if (Py_Type(mapping) == &EncodingMapType) {
+ if (Py_TYPE(mapping) == &EncodingMapType) {
int res = encoding_map_lookup(p[collendpos], mapping);
if (res != -1)
break;
@@ -4920,7 +4920,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
PyErr_Format(PyExc_TypeError,
"sequence item %zd: expected string or Unicode,"
" %.80s found",
- i, Py_Type(item)->tp_name);
+ i, Py_TYPE(item)->tp_name);
goto onError;
}
item = PyUnicode_FromObject(item);
@@ -5920,7 +5920,7 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
PyErr_Format(PyExc_TypeError,
"encoder did not return a string/unicode object "
"(type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
return NULL;
}
@@ -5956,7 +5956,7 @@ unicode_decode(PyUnicodeObject *self, PyObject *args)
PyErr_Format(PyExc_TypeError,
"decoder did not return a string/unicode object "
"(type=%.400s)",
- Py_Type(v)->tp_name);
+ Py_TYPE(v)->tp_name);
Py_DECREF(v);
return NULL;
}
@@ -7777,7 +7777,7 @@ PyObject *PyUnicode_Format(PyObject *format,
arglen = -1;
argidx = -2;
}
- if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) &&
+ if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) &&
!PyObject_TypeCheck(args, &PyBaseString_Type))
dict = args;
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index d26d5d1..0a87b53 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -105,7 +105,7 @@ weakref_dealloc(PyObject *self)
{
PyObject_GC_UnTrack(self);
clear_weakref((PyWeakReference *) self);
- Py_Type(self)->tp_free(self);
+ Py_TYPE(self)->tp_free(self);
}
@@ -172,7 +172,7 @@ weakref_repr(PyWeakReference *self)
name ? "<weakref at %p; to '%.50s' at %p (%s)>"
: "<weakref at %p; to '%.50s' at %p>",
self,
- Py_Type(PyWeakref_GET_OBJECT(self))->tp_name,
+ Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name,
PyWeakref_GET_OBJECT(self),
name);
Py_XDECREF(nameobj);
@@ -274,10 +274,10 @@ weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyWeakReference *ref, *proxy;
PyWeakReference **list;
- if (!PyType_SUPPORTS_WEAKREFS(Py_Type(ob))) {
+ if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
PyErr_Format(PyExc_TypeError,
"cannot create weak reference to '%s' object",
- Py_Type(ob)->tp_name);
+ Py_TYPE(ob)->tp_name);
return NULL;
}
if (callback == Py_None)
@@ -446,7 +446,7 @@ proxy_repr(PyWeakReference *proxy)
char buf[160];
PyOS_snprintf(buf, sizeof(buf),
"<weakproxy at %p to %.100s at %p>", proxy,
- Py_Type(PyWeakref_GET_OBJECT(proxy))->tp_name,
+ Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name,
PyWeakref_GET_OBJECT(proxy));
return PyString_FromString(buf);
}
@@ -719,10 +719,10 @@ PyWeakref_NewRef(PyObject *ob, PyObject *callback)
PyWeakReference **list;
PyWeakReference *ref, *proxy;
- if (!PyType_SUPPORTS_WEAKREFS(Py_Type(ob))) {
+ if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
PyErr_Format(PyExc_TypeError,
"cannot create weak reference to '%s' object",
- Py_Type(ob)->tp_name);
+ Py_TYPE(ob)->tp_name);
return NULL;
}
list = GET_WEAKREFS_LISTPTR(ob);
@@ -778,10 +778,10 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
PyWeakReference **list;
PyWeakReference *ref, *proxy;
- if (!PyType_SUPPORTS_WEAKREFS(Py_Type(ob))) {
+ if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) {
PyErr_Format(PyExc_TypeError,
"cannot create weak reference to '%s' object",
- Py_Type(ob)->tp_name);
+ Py_TYPE(ob)->tp_name);
return NULL;
}
list = GET_WEAKREFS_LISTPTR(ob);
@@ -804,9 +804,9 @@ PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
PyWeakReference *prev;
if (PyCallable_Check(ob))
- Py_Type(result) = &_PyWeakref_CallableProxyType;
+ Py_TYPE(result) = &_PyWeakref_CallableProxyType;
else
- Py_Type(result) = &_PyWeakref_ProxyType;
+ Py_TYPE(result) = &_PyWeakref_ProxyType;
get_basic_refs(*list, &ref, &proxy);
if (callback == NULL) {
if (proxy != NULL) {
@@ -871,7 +871,7 @@ PyObject_ClearWeakRefs(PyObject *object)
PyWeakReference **list;
if (object == NULL
- || !PyType_SUPPORTS_WEAKREFS(Py_Type(object))
+ || !PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))
|| object->ob_refcnt != 0) {
PyErr_BadInternalCall();
return;