diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-19 02:45:37 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-19 02:45:37 (GMT) |
commit | 90aa7646affbaee9628ca6ea6a702aec17b3b550 (patch) | |
tree | e820962e9658a92c7147b686f8aa88c7658c5949 /Modules | |
parent | 99170a5dbf4cfee78b578672b6821e855f92594b (diff) | |
download | cpython-90aa7646affbaee9628ca6ea6a702aec17b3b550.zip cpython-90aa7646affbaee9628ca6ea6a702aec17b3b550.tar.gz cpython-90aa7646affbaee9628ca6ea6a702aec17b3b550.tar.bz2 |
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Diffstat (limited to 'Modules')
54 files changed, 329 insertions, 329 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 3452a61..fb71161 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -203,13 +203,13 @@ static PyObject* DBPermissionsError; /* EPERM */ static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type; -#define DBObject_Check(v) (Py_Type(v) == &DB_Type) -#define DBCursorObject_Check(v) (Py_Type(v) == &DBCursor_Type) -#define DBEnvObject_Check(v) (Py_Type(v) == &DBEnv_Type) -#define DBTxnObject_Check(v) (Py_Type(v) == &DBTxn_Type) -#define DBLockObject_Check(v) (Py_Type(v) == &DBLock_Type) +#define DBObject_Check(v) (Py_TYPE(v) == &DB_Type) +#define DBCursorObject_Check(v) (Py_TYPE(v) == &DBCursor_Type) +#define DBEnvObject_Check(v) (Py_TYPE(v) == &DBEnv_Type) +#define DBTxnObject_Check(v) (Py_TYPE(v) == &DBTxn_Type) +#define DBLockObject_Check(v) (Py_TYPE(v) == &DBLock_Type) #if (DBVER >= 43) -#define DBSequenceObject_Check(v) (Py_Type(v) == &DBSequence_Type) +#define DBSequenceObject_Check(v) (Py_TYPE(v) == &DBSequence_Type) #endif @@ -461,7 +461,7 @@ make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags, else { PyErr_Format(PyExc_TypeError, "buffer or int object expected for key, %s found", - Py_Type(keyobj)->tp_name); + Py_TYPE(keyobj)->tp_name); return 0; } @@ -611,7 +611,7 @@ static int makeDBError(int err) static void makeTypeError(char* expected, PyObject* found) { PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.", - expected, Py_Type(found)->tp_name); + expected, Py_TYPE(found)->tp_name); } @@ -1176,7 +1176,7 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData, Py_ssize_t size; CLEAR_DBT(*secKey); - size = Py_Size(result); + size = Py_SIZE(result); if (PyBytes_Check(result)) data = PyBytes_AS_STRING(result); else @@ -5656,13 +5656,13 @@ PyMODINIT_FUNC init_bsddb(void) /* Initialize the type of the new type objects here; doing it here is required for portability to Windows without requiring C++. */ - Py_Type(&DB_Type) = &PyType_Type; - Py_Type(&DBCursor_Type) = &PyType_Type; - Py_Type(&DBEnv_Type) = &PyType_Type; - Py_Type(&DBTxn_Type) = &PyType_Type; - Py_Type(&DBLock_Type) = &PyType_Type; + Py_TYPE(&DB_Type) = &PyType_Type; + Py_TYPE(&DBCursor_Type) = &PyType_Type; + Py_TYPE(&DBEnv_Type) = &PyType_Type; + Py_TYPE(&DBTxn_Type) = &PyType_Type; + Py_TYPE(&DBLock_Type) = &PyType_Type; #if (DBVER >= 43) - Py_Type(&DBSequence_Type) = &PyType_Type; + Py_TYPE(&DBSequence_Type) = &PyType_Type; #endif diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 0d1df5f..493f314 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -583,7 +583,7 @@ deque_dealloc(dequeobject *deque) } deque->leftblock = NULL; deque->rightblock = NULL; - Py_Type(deque)->tp_free(deque); + Py_TYPE(deque)->tp_free(deque); } static int @@ -619,9 +619,9 @@ static PyObject * deque_copy(PyObject *deque) { if (((dequeobject *)deque)->maxlen == -1) - return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "O", deque, NULL); + return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL); else - return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "Oi", + return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", deque, ((dequeobject *)deque)->maxlen, NULL); } @@ -642,14 +642,14 @@ deque_reduce(dequeobject *deque) } if (dict == NULL) { if (deque->maxlen == -1) - result = Py_BuildValue("O(O)", Py_Type(deque), aslist); + result = Py_BuildValue("O(O)", Py_TYPE(deque), aslist); else - result = Py_BuildValue("O(Oi)", Py_Type(deque), aslist, deque->maxlen); + result = Py_BuildValue("O(Oi)", Py_TYPE(deque), aslist, deque->maxlen); } else { if (deque->maxlen == -1) - result = Py_BuildValue("O(OO)O", Py_Type(deque), aslist, Py_None, dict); + result = Py_BuildValue("O(OO)O", Py_TYPE(deque), aslist, Py_None, dict); else - result = Py_BuildValue("O(Oi)O", Py_Type(deque), aslist, deque->maxlen, dict); + result = Py_BuildValue("O(Oi)O", Py_TYPE(deque), aslist, deque->maxlen, dict); } Py_XDECREF(dict); Py_DECREF(aslist); @@ -921,7 +921,7 @@ static void dequeiter_dealloc(dequeiterobject *dio) { Py_XDECREF(dio->deque); - Py_Type(dio)->tp_free(dio); + Py_TYPE(dio)->tp_free(dio); } static PyObject * @@ -1129,7 +1129,7 @@ defdict_copy(defdictobject *dd) whose class constructor has the same signature. Subclasses that define a different constructor signature must override copy(). */ - return PyObject_CallFunctionObjArgs((PyObject*)Py_Type(dd), + return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd), dd->default_factory, dd, NULL); } @@ -1172,7 +1172,7 @@ defdict_reduce(defdictobject *dd) Py_DECREF(args); return NULL; } - result = PyTuple_Pack(5, Py_Type(dd), args, + result = PyTuple_Pack(5, Py_TYPE(dd), args, Py_None, Py_None, items); Py_DECREF(items); Py_DECREF(args); diff --git a/Modules/_csv.c b/Modules/_csv.c index aee490c..9a72955 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -81,7 +81,7 @@ typedef struct { static PyTypeObject Reader_Type; -#define ReaderObject_Check(v) (Py_Type(v) == &Reader_Type) +#define ReaderObject_Check(v) (Py_TYPE(v) == &Reader_Type) typedef struct { PyObject_HEAD @@ -284,7 +284,7 @@ static void Dialect_dealloc(DialectObj *self) { Py_XDECREF(self->lineterminator); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static char *dialect_kws[] = { diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index dd4b754..5da7de0 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -328,7 +328,7 @@ CDataType_from_param(PyObject *type, PyObject *value) Py_INCREF(value); return value; } - ob_name = (ob) ? Py_Type(ob)->tp_name : "???"; + ob_name = (ob) ? Py_TYPE(ob)->tp_name : "???"; PyErr_Format(PyExc_TypeError, "expected %s instance instead of pointer to %s", ((PyTypeObject *)type)->tp_name, ob_name); @@ -344,7 +344,7 @@ CDataType_from_param(PyObject *type, PyObject *value) PyErr_Format(PyExc_TypeError, "expected %s instance instead of %s", ((PyTypeObject *)type)->tp_name, - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return NULL; } @@ -798,7 +798,7 @@ CharArray_set_value(CDataObject *self, PyObject *value) } else if (!PyString_Check(value)) { PyErr_Format(PyExc_TypeError, "str/bytes expected instead of %s instance", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } else Py_INCREF(value); @@ -858,7 +858,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value) } else if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string expected instead of %s instance", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } else Py_INCREF(value); @@ -2075,7 +2075,7 @@ static void CData_dealloc(PyObject *self) { CData_clear((CDataObject *)self); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyMemberDef CData_members[] = { @@ -2334,7 +2334,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, PyErr_Format(PyExc_TypeError, "expected %s instance, got %s", ((PyTypeObject *)type)->tp_name, - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return NULL; } } @@ -2365,7 +2365,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, if (p1->proto != p2->proto) { PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", - Py_Type(value)->tp_name, + Py_TYPE(value)->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; } @@ -2384,7 +2384,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, } PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", - Py_Type(value)->tp_name, + Py_TYPE(value)->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; } @@ -2645,7 +2645,7 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index) Py_SAFE_DOWNCAST(index, Py_ssize_t, int), PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name : - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); return 0; } @@ -3430,7 +3430,7 @@ static void CFuncPtr_dealloc(CFuncPtrObject *self) { CFuncPtr_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * @@ -3440,11 +3440,11 @@ CFuncPtr_repr(CFuncPtrObject *self) if (self->index) return PyUnicode_FromFormat("<COM method offset %d: %s at %p>", self->index - 0x1000, - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, self); #endif return PyUnicode_FromFormat("<%s object at %p>", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, self); } @@ -4078,7 +4078,7 @@ static PyGetSetDef Simple_getsets[] = { static PyObject * Simple_from_outparm(PyObject *self, PyObject *args) { - if (IsSimpleSubType((PyObject *)Py_Type(self))) { + if (IsSimpleSubType((PyObject *)Py_TYPE(self))) { Py_INCREF(self); return self; } @@ -4116,9 +4116,9 @@ Simple_repr(CDataObject *self) PyObject *val, *name, *args, *result; static PyObject *format; - if (Py_Type(self)->tp_base != &Simple_Type) { + if (Py_TYPE(self)->tp_base != &Simple_Type) { return PyUnicode_FromFormat("<%s object at %p>", - Py_Type(self)->tp_name, self); + Py_TYPE(self)->tp_name, self); } if (format == NULL) { @@ -4131,7 +4131,7 @@ Simple_repr(CDataObject *self) if (val == NULL) return NULL; - name = PyUnicode_FromString(Py_Type(self)->tp_name); + name = PyUnicode_FromString(Py_TYPE(self)->tp_name); if (name == NULL) { Py_DECREF(val); return NULL; @@ -4302,7 +4302,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure) PyErr_Format(PyExc_TypeError, "expected %s instead of %s", ((PyTypeObject *)(stgdict->proto))->tp_name, - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } @@ -4588,7 +4588,7 @@ comerror_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *a; int status; - if (!_PyArg_NoKeywords(Py_Type(self)->tp_name, kwds)) + if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) return -1; if (!PyArg_ParseTuple(args, "OOO:COMError", &hresult, &text, &details)) @@ -4703,7 +4703,7 @@ cast_check_pointertype(PyObject *arg) "cast() argument 2 must be a pointer type, not %s", PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name - : Py_Type(arg)->tp_name); + : Py_TYPE(arg)->tp_name); return 0; } @@ -4830,37 +4830,37 @@ init_ctypes(void) if (PyType_Ready(&CData_Type) < 0) return; - Py_Type(&Struct_Type) = &StructType_Type; + Py_TYPE(&Struct_Type) = &StructType_Type; Struct_Type.tp_base = &CData_Type; if (PyType_Ready(&Struct_Type) < 0) return; PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type); - Py_Type(&Union_Type) = &UnionType_Type; + Py_TYPE(&Union_Type) = &UnionType_Type; Union_Type.tp_base = &CData_Type; if (PyType_Ready(&Union_Type) < 0) return; PyModule_AddObject(m, "Union", (PyObject *)&Union_Type); - Py_Type(&Pointer_Type) = &PointerType_Type; + Py_TYPE(&Pointer_Type) = &PointerType_Type; Pointer_Type.tp_base = &CData_Type; if (PyType_Ready(&Pointer_Type) < 0) return; PyModule_AddObject(m, "_Pointer", (PyObject *)&Pointer_Type); - Py_Type(&Array_Type) = &ArrayType_Type; + Py_TYPE(&Array_Type) = &ArrayType_Type; Array_Type.tp_base = &CData_Type; if (PyType_Ready(&Array_Type) < 0) return; PyModule_AddObject(m, "Array", (PyObject *)&Array_Type); - Py_Type(&Simple_Type) = &SimpleType_Type; + Py_TYPE(&Simple_Type) = &SimpleType_Type; Simple_Type.tp_base = &CData_Type; if (PyType_Ready(&Simple_Type) < 0) return; PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type); - Py_Type(&CFuncPtr_Type) = &CFuncPtrType_Type; + Py_TYPE(&CFuncPtr_Type) = &CFuncPtrType_Type; CFuncPtr_Type.tp_base = &CData_Type; if (PyType_Ready(&CFuncPtr_Type) < 0) return; diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index befb31b..8f6b957 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1153,7 +1153,7 @@ call_commethod(PyObject *self, PyObject *args) if (!CDataObject_Check(pcom) || (pcom->b_size != sizeof(void *))) { PyErr_Format(PyExc_TypeError, "COM Pointer expected instead of %s instance", - Py_Type(pcom)->tp_name); + Py_TYPE(pcom)->tp_name); return NULL; } @@ -1393,7 +1393,7 @@ byref(PyObject *self, PyObject *obj) if (!CDataObject_Check(obj)) { PyErr_Format(PyExc_TypeError, "byref() argument must be a ctypes instance, not '%s'", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); return NULL; } diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index a873642..e7a534e 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1349,7 +1349,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length) data = PyString_AS_STRING(value); if (!data) return NULL; - size = strlen(data); /* XXX Why not Py_Size(value)? */ + size = strlen(data); /* XXX Why not Py_SIZE(value)? */ if (size < length) { /* This will copy the leading NUL character * if there is space for it. diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index d38380b..11a1a63 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -183,7 +183,7 @@ MakeFields(PyObject *type, CFieldObject *descr, Py_DECREF(fieldlist); return -1; } - if (Py_Type(fdescr) != &CField_Type) { + if (Py_TYPE(fdescr) != &CField_Type) { PyErr_SetString(PyExc_TypeError, "unexpected type"); Py_DECREF(fdescr); Py_DECREF(fieldlist); @@ -206,7 +206,7 @@ MakeFields(PyObject *type, CFieldObject *descr, Py_DECREF(fieldlist); return -1; } - assert(Py_Type(new_descr) == &CField_Type); + assert(Py_TYPE(new_descr) == &CField_Type); new_descr->size = fdescr->size; new_descr->offset = fdescr->offset + offset; new_descr->index = fdescr->index + index; @@ -254,7 +254,7 @@ MakeAnonFields(PyObject *type) Py_DECREF(anon_names); return -1; } - assert(Py_Type(descr) == &CField_Type); + assert(Py_TYPE(descr) == &CField_Type); descr->anonymous = 1; /* descr is in the field descriptor. */ diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index e73d986..9bdd194 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -56,7 +56,7 @@ typedef struct { PyTypeObject PyCursesPanel_Type; -#define PyCursesPanel_Check(v) (Py_Type(v) == &PyCursesPanel_Type) +#define PyCursesPanel_Check(v) (Py_TYPE(v) == &PyCursesPanel_Type) /* Some helper functions. The problem is that there's always a window associated with a panel. To ensure that Python's GC doesn't pull @@ -457,7 +457,7 @@ init_curses_panel(void) PyObject *m, *d, *v; /* Initialize object type */ - Py_Type(&PyCursesPanel_Type) = &PyType_Type; + Py_TYPE(&PyCursesPanel_Type) = &PyType_Type; import_curses(); diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index d1cd1551..ea98d08 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -2709,7 +2709,7 @@ init_curses(void) static void *PyCurses_API[PyCurses_API_pointers]; /* Initialize object type */ - Py_Type(&PyCursesWindow_Type) = &PyType_Type; + Py_TYPE(&PyCursesWindow_Type) = &PyType_Type; /* Initialize the C API pointer array */ PyCurses_API[0] = (void *)&PyCursesWindow_Type; diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 72c157d..97297b8 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -248,7 +248,7 @@ typedef struct { static PyTypeObject Element_Type; -#define Element_CheckExact(op) (Py_Type(op) == &Element_Type) +#define Element_CheckExact(op) (Py_TYPE(op) == &Element_Type) /* -------------------------------------------------------------------- */ /* element constructor and destructor */ @@ -1174,7 +1174,7 @@ element_setslice(PyObject* self_, Py_ssize_t start, Py_ssize_t end, PyObject* it /* FIXME: support arbitrary sequences? */ PyErr_Format( PyExc_TypeError, - "expected list, not \"%.200s\"", Py_Type(item)->tp_name + "expected list, not \"%.200s\"", Py_TYPE(item)->tp_name ); return -1; } @@ -1407,7 +1407,7 @@ typedef struct { static PyTypeObject TreeBuilder_Type; -#define TreeBuilder_CheckExact(op) (Py_Type(op) == &TreeBuilder_Type) +#define TreeBuilder_CheckExact(op) (Py_TYPE(op) == &TreeBuilder_Type) /* -------------------------------------------------------------------- */ /* constructor and destructor */ @@ -1574,7 +1574,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data) Py_INCREF(data); self->data = data; } else { /* more than one item; use a list to collect items */ - if (PyString_CheckExact(self->data) && Py_Refcnt(self->data) == 1 && + if (PyString_CheckExact(self->data) && Py_REFCNT(self->data) == 1 && PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) { /* expat often generates single character data sections; handle the most common case by resizing the existing string... */ @@ -2550,9 +2550,9 @@ init_elementtree(void) #endif /* Patch object type */ - Py_Type(&Element_Type) = Py_Type(&TreeBuilder_Type) = &PyType_Type; + Py_TYPE(&Element_Type) = Py_TYPE(&TreeBuilder_Type) = &PyType_Type; #if defined(USE_EXPAT) - Py_Type(&XMLParser_Type) = &PyType_Type; + Py_TYPE(&XMLParser_Type) = &PyType_Type; #endif m = Py_InitModule("_elementtree", _functions); diff --git a/Modules/_fileio.c b/Modules/_fileio.c index f3b20c9..7490ed6 100644 --- a/Modules/_fileio.c +++ b/Modules/_fileio.c @@ -304,7 +304,7 @@ fileio_dealloc(PyFileIOObject *self) } } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 7564c3a..167f906 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -81,7 +81,7 @@ partial_dealloc(partialobject *pto) Py_XDECREF(pto->args); Py_XDECREF(pto->kw); Py_XDECREF(pto->dict); - Py_Type(pto)->tp_free(pto); + Py_TYPE(pto)->tp_free(pto); } static PyObject * diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 487240e..1791efe 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -510,7 +510,7 @@ init_hashlib(void) * but having some be unsupported. Only init appropriate * constants. */ - Py_Type(&EVPtype) = &PyType_Type; + Py_TYPE(&EVPtype) = &PyType_Type; if (PyType_Ready(&EVPtype) < 0) return; diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 1707679..e0446ec 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -120,7 +120,7 @@ typedef struct { static PyTypeObject PyProfiler_Type; #define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type) -#define PyProfiler_CheckExact(op) (Py_Type(op) == &PyProfiler_Type) +#define PyProfiler_CheckExact(op) (Py_TYPE(op) == &PyProfiler_Type) /*** External Timers ***/ @@ -207,7 +207,7 @@ normalizeUserObj(PyObject *obj) PyObject *self = fn->m_self; PyObject *name = PyUnicode_FromString(fn->m_ml->ml_name); if (name != NULL) { - PyObject *mo = _PyType_Lookup(Py_Type(self), name); + PyObject *mo = _PyType_Lookup(Py_TYPE(self), name); Py_XINCREF(mo); Py_DECREF(name); if (mo != NULL) { @@ -756,7 +756,7 @@ profiler_dealloc(ProfilerObject *op) flush_unmatched(op); clearEntries(op); Py_XDECREF(op->externalTimer); - Py_Type(op)->tp_free(op); + Py_TYPE(op)->tp_free(op); } static int diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index c791909..957422c 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -84,7 +84,7 @@ typedef struct { static PyTypeObject Random_Type; -#define RandomObject_Check(v) (Py_Type(v) == &Random_Type) +#define RandomObject_Check(v) (Py_TYPE(v) == &Random_Type) /* Random methods */ @@ -405,7 +405,7 @@ random_jumpahead(RandomObject *self, PyObject *n) if (!PyLong_Check(n)) { PyErr_Format(PyExc_TypeError, "jumpahead requires an " "integer, not '%s'", - Py_Type(n)->tp_name); + Py_TYPE(n)->tp_name); return NULL; } diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 2f50e6a..3cb540a 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -51,7 +51,7 @@ void pysqlite_node_dealloc(pysqlite_Node* self) Py_DECREF(self->key); Py_DECREF(self->data); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs) @@ -109,7 +109,7 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self) } Py_DECREF(self->mapping); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 92a3e51..9451881 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -205,7 +205,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self) Py_XDECREF(self->collations); Py_XDECREF(self->statements); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 334f94b..d723cdb 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -134,7 +134,7 @@ void pysqlite_cursor_dealloc(pysqlite_Cursor* self) Py_XDECREF(self->row_factory); Py_XDECREF(self->next_row); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyObject* _pysqlite_get_converter(PyObject* key) diff --git a/Modules/_sqlite/prepare_protocol.c b/Modules/_sqlite/prepare_protocol.c index c979610..c018c96 100644 --- a/Modules/_sqlite/prepare_protocol.c +++ b/Modules/_sqlite/prepare_protocol.c @@ -30,7 +30,7 @@ int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* arg void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self) { - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyTypeObject pysqlite_PrepareProtocolType= { @@ -78,6 +78,6 @@ PyTypeObject pysqlite_PrepareProtocolType= { extern int pysqlite_prepare_protocol_setup_types(void) { pysqlite_PrepareProtocolType.tp_new = PyType_GenericNew; - Py_Type(&pysqlite_PrepareProtocolType)= &PyType_Type; + Py_TYPE(&pysqlite_PrepareProtocolType)= &PyType_Type; return PyType_Ready(&pysqlite_PrepareProtocolType); } diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index dfb6363..a851579 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -30,7 +30,7 @@ void pysqlite_row_dealloc(pysqlite_Row* self) Py_XDECREF(self->data); Py_XDECREF(self->description); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs) diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index 126ba6f..d280a67 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -307,7 +307,7 @@ void pysqlite_statement_dealloc(pysqlite_Statement* self) PyObject_ClearWeakRefs((PyObject*)self); } - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } /* diff --git a/Modules/_sre.c b/Modules/_sre.c index 33f3759..19e7bdc 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -1685,7 +1685,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize) /* get pointer to string buffer */ view.len = -1; - buffer = Py_Type(string)->tp_as_buffer; + buffer = Py_TYPE(string)->tp_as_buffer; if (!buffer || !buffer->bf_getbuffer || (*buffer->bf_getbuffer)(string, &view, PyBUF_SIMPLE) < 0) { PyErr_SetString(PyExc_TypeError, "expected string or buffer"); diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 58b04a6..13d27cc 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -127,7 +127,7 @@ static int check_socket_and_wait_for_timeout(PySocketSockObject *s, static PyObject *PySSL_peercert(PySSLObject *self, PyObject *args); static PyObject *PySSL_cipher(PySSLObject *self); -#define PySSLObject_Check(v) (Py_Type(v) == &PySSL_Type) +#define PySSLObject_Check(v) (Py_TYPE(v) == &PySSL_Type) typedef enum { SOCKET_IS_NONBLOCKING, @@ -1451,7 +1451,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg) if (!PyUnicode_Check(arg)) return PyErr_Format(PyExc_TypeError, "RAND_egd() expected string, found %s", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); bytes = RAND_egd(PyUnicode_AsString(arg)); if (bytes == -1) { PyErr_SetString(PySSLErrorObject, @@ -1568,7 +1568,7 @@ init_ssl(void) { PyObject *m, *d; - Py_Type(&PySSL_Type) = &PyType_Type; + Py_TYPE(&PySSL_Type) = &PyType_Type; m = Py_InitModule3("_ssl", PySSL_methods, module_doc); if (m == NULL) diff --git a/Modules/_struct.c b/Modules/_struct.c index dd92e0c..3c02bc9 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -67,7 +67,7 @@ typedef struct { #define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType) -#define PyStruct_CheckExact(op) (Py_Type(op) == &PyStructType) +#define PyStruct_CheckExact(op) (Py_TYPE(op) == &PyStructType) /* Exception */ @@ -126,7 +126,7 @@ get_pylong(PyObject *v) Py_INCREF(v); return v; } - m = Py_Type(v)->tp_as_number; + m = Py_TYPE(v)->tp_as_number; if (m != NULL && m->nb_long != NULL) { v = m->nb_long(v); if (v == NULL) @@ -1485,7 +1485,7 @@ s_dealloc(PyStructObject *s) PyMem_FREE(s->s_codes); } Py_XDECREF(s->s_format); - Py_Type(s)->tp_free((PyObject *)s); + Py_TYPE(s)->tp_free((PyObject *)s); } static PyObject * @@ -1870,7 +1870,7 @@ init_struct(void) if (m == NULL) return; - Py_Type(&PyStructType) = &PyType_Type; + Py_TYPE(&PyStructType) = &PyType_Type; if (PyType_Ready(&PyStructType) < 0) return; diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 7de5e0d..d89a513 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1057,7 +1057,7 @@ init_testcapi(void) if (m == NULL) return; - Py_Type(&test_structmembersType)=&PyType_Type; + Py_TYPE(&test_structmembersType)=&PyType_Type; Py_INCREF(&test_structmembersType); PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 2a341ab..bc54b7b 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -262,12 +262,12 @@ typedef struct { Tcl_ObjType *StringType; } TkappObject; -#define Tkapp_Check(v) (Py_Type(v) == &Tkapp_Type) +#define Tkapp_Check(v) (Py_TYPE(v) == &Tkapp_Type) #define Tkapp_Interp(v) (((TkappObject *) (v))->interp) #define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v)) #define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \ -(void *) v, Py_Refcnt(v))) +(void *) v, Py_REFCNT(v))) @@ -3016,7 +3016,7 @@ init_tkinter(void) { PyObject *m, *d; - Py_Type(&Tkapp_Type) = &PyType_Type; + Py_TYPE(&Tkapp_Type) = &PyType_Type; #ifdef WITH_THREAD tcl_lock = PyThread_allocate_lock(); @@ -3044,10 +3044,10 @@ init_tkinter(void) PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type); - Py_Type(&Tktt_Type) = &PyType_Type; + Py_TYPE(&Tktt_Type) = &PyType_Type; PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type); - Py_Type(&PyTclObject_Type) = &PyType_Type; + Py_TYPE(&PyTclObject_Type) = &PyType_Type; PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type); #ifdef TK_AQUA diff --git a/Modules/_weakref.c b/Modules/_weakref.c index f4ee3a3..b187a26 100644 --- a/Modules/_weakref.c +++ b/Modules/_weakref.c @@ -14,7 +14,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *object) { PyObject *result = NULL; - if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { + if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); result = PyLong_FromSsize_t(_PyWeakref_GetWeakrefCount(*list)); @@ -35,7 +35,7 @@ weakref_getweakrefs(PyObject *self, PyObject *object) { PyObject *result = NULL; - if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { + if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list); diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 86afc92..eb12625 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -41,7 +41,7 @@ typedef struct arrayobject { static PyTypeObject Arraytype; #define array_Check(op) PyObject_TypeCheck(op, &Arraytype) -#define array_CheckExact(op) (Py_Type(op) == &Arraytype) +#define array_CheckExact(op) (Py_TYPE(op) == &Arraytype) static int array_resize(arrayobject *self, Py_ssize_t newsize) @@ -55,9 +55,9 @@ array_resize(arrayobject *self, Py_ssize_t newsize) */ if (self->allocated >= newsize && - Py_Size(self) < newsize + 16 && + Py_SIZE(self) < newsize + 16 && self->ob_item != NULL) { - Py_Size(self) = newsize; + Py_SIZE(self) = newsize; return 0; } @@ -79,7 +79,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize) * memory critical. */ - _new_size = (newsize >> 4) + (Py_Size(self) < 8 ? 3 : 7) + newsize; + _new_size = (newsize >> 4) + (Py_SIZE(self) < 8 ? 3 : 7) + newsize; items = self->ob_item; /* XXX The following multiplication and division does not optimize away like it does for lists since the size is not known at compile time */ @@ -92,7 +92,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize) return -1; } self->ob_item = items; - Py_Size(self) = newsize; + Py_SIZE(self) = newsize; self->allocated = _new_size; return 0; } @@ -421,7 +421,7 @@ newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr) if (op == NULL) { return NULL; } - Py_Size(op) = size; + Py_SIZE(op) = size; if (size <= 0) { op->ob_item = NULL; } @@ -445,7 +445,7 @@ getarrayitem(PyObject *op, Py_ssize_t i) register arrayobject *ap; assert(array_Check(op)); ap = (arrayobject *)op; - assert(i>=0 && i<Py_Size(ap)); + assert(i>=0 && i<Py_SIZE(ap)); return (*ap->ob_descr->getitem)(ap, i); } @@ -453,7 +453,7 @@ static int ins1(arrayobject *self, Py_ssize_t where, PyObject *v) { char *items; - Py_ssize_t n = Py_Size(self); + Py_ssize_t n = Py_SIZE(self); if (v == NULL) { PyErr_BadInternalCall(); return -1; @@ -488,7 +488,7 @@ array_dealloc(arrayobject *op) PyObject_ClearWeakRefs((PyObject *) op); if (op->ob_item != NULL) PyMem_DEL(op->ob_item); - Py_Type(op)->tp_free((PyObject *)op); + Py_TYPE(op)->tp_free((PyObject *)op); } static PyObject * @@ -508,7 +508,7 @@ array_richcompare(PyObject *v, PyObject *w, int op) va = (arrayobject *)v; wa = (arrayobject *)w; - if (Py_Size(va) != Py_Size(wa) && (op == Py_EQ || op == Py_NE)) { + if (Py_SIZE(va) != Py_SIZE(wa) && (op == Py_EQ || op == Py_NE)) { /* Shortcut: if the lengths differ, the arrays differ */ if (op == Py_EQ) res = Py_False; @@ -520,7 +520,7 @@ array_richcompare(PyObject *v, PyObject *w, int op) /* Search for the first index where items are different */ k = 1; - for (i = 0; i < Py_Size(va) && i < Py_Size(wa); i++) { + for (i = 0; i < Py_SIZE(va) && i < Py_SIZE(wa); i++) { vi = getarrayitem(v, i); wi = getarrayitem(w, i); if (vi == NULL || wi == NULL) { @@ -539,8 +539,8 @@ array_richcompare(PyObject *v, PyObject *w, int op) if (k) { /* No more items to compare -- compare sizes */ - Py_ssize_t vs = Py_Size(va); - Py_ssize_t ws = Py_Size(wa); + Py_ssize_t vs = Py_SIZE(va); + Py_ssize_t ws = Py_SIZE(wa); int cmp; switch (op) { case Py_LT: cmp = vs < ws; break; @@ -580,13 +580,13 @@ array_richcompare(PyObject *v, PyObject *w, int op) static Py_ssize_t array_length(arrayobject *a) { - return Py_Size(a); + return Py_SIZE(a); } static PyObject * array_item(arrayobject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "array index out of range"); return NULL; } @@ -599,14 +599,14 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh) arrayobject *np; 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 < 0) ihigh = 0; 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); np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr); if (np == NULL) return NULL; @@ -618,7 +618,7 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh) static PyObject * array_copy(arrayobject *a, PyObject *unused) { - return array_slice(a, 0, Py_Size(a)); + return array_slice(a, 0, Py_SIZE(a)); } PyDoc_STRVAR(copy_doc, @@ -634,7 +634,7 @@ array_concat(arrayobject *a, PyObject *bb) if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only append array (not \"%.200s\") to array", - Py_Type(bb)->tp_name); + Py_TYPE(bb)->tp_name); return NULL; } #define b ((arrayobject *)bb) @@ -642,14 +642,14 @@ array_concat(arrayobject *a, PyObject *bb) PyErr_BadArgument(); return NULL; } - size = Py_Size(a) + Py_Size(b); + size = Py_SIZE(a) + Py_SIZE(b); np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) { return NULL; } - memcpy(np->ob_item, a->ob_item, Py_Size(a)*a->ob_descr->itemsize); - memcpy(np->ob_item + Py_Size(a)*a->ob_descr->itemsize, - b->ob_item, Py_Size(b)*b->ob_descr->itemsize); + memcpy(np->ob_item, a->ob_item, Py_SIZE(a)*a->ob_descr->itemsize); + memcpy(np->ob_item + Py_SIZE(a)*a->ob_descr->itemsize, + b->ob_item, Py_SIZE(b)*b->ob_descr->itemsize); return (PyObject *)np; #undef b } @@ -664,12 +664,12 @@ array_repeat(arrayobject *a, Py_ssize_t n) Py_ssize_t nbytes; if (n < 0) n = 0; - size = Py_Size(a) * n; + size = Py_SIZE(a) * n; np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) return NULL; p = np->ob_item; - nbytes = Py_Size(a) * a->ob_descr->itemsize; + nbytes = Py_SIZE(a) * a->ob_descr->itemsize; for (i = 0; i < n; i++) { memcpy(p, a->ob_item, nbytes); p += nbytes; @@ -687,7 +687,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) if (v == NULL) n = 0; else if (array_Check(v)) { - n = Py_Size(b); + n = Py_SIZE(b); if (a == b) { /* Special case "a[i:j] = a" -- copy b first */ int ret; @@ -706,44 +706,44 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) else { PyErr_Format(PyExc_TypeError, "can only assign array (not \"%.200s\") to array slice", - Py_Type(v)->tp_name); + Py_TYPE(v)->tp_name); return -1; } 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 < 0) ihigh = 0; 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); item = a->ob_item; d = n - (ihigh-ilow); if (d < 0) { /* Delete -d items */ memmove(item + (ihigh+d)*a->ob_descr->itemsize, item + ihigh*a->ob_descr->itemsize, - (Py_Size(a)-ihigh)*a->ob_descr->itemsize); - Py_Size(a) += d; - PyMem_RESIZE(item, char, Py_Size(a)*a->ob_descr->itemsize); + (Py_SIZE(a)-ihigh)*a->ob_descr->itemsize); + Py_SIZE(a) += d; + PyMem_RESIZE(item, char, Py_SIZE(a)*a->ob_descr->itemsize); /* Can't fail */ a->ob_item = item; - a->allocated = Py_Size(a); + a->allocated = Py_SIZE(a); } else if (d > 0) { /* Insert d items */ PyMem_RESIZE(item, char, - (Py_Size(a) + d)*a->ob_descr->itemsize); + (Py_SIZE(a) + d)*a->ob_descr->itemsize); if (item == NULL) { PyErr_NoMemory(); return -1; } memmove(item + (ihigh+d)*a->ob_descr->itemsize, item + ihigh*a->ob_descr->itemsize, - (Py_Size(a)-ihigh)*a->ob_descr->itemsize); + (Py_SIZE(a)-ihigh)*a->ob_descr->itemsize); a->ob_item = item; - Py_Size(a) += d; - a->allocated = Py_Size(a); + Py_SIZE(a) += d; + a->allocated = Py_SIZE(a); } if (n > 0) memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item, @@ -755,7 +755,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) static int array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; @@ -782,7 +782,7 @@ array_iter_extend(arrayobject *self, PyObject *bb) return -1; while ((v = PyIter_Next(it)) != NULL) { - if (ins1(self, (int) Py_Size(self), v) != 0) { + if (ins1(self, (int) Py_SIZE(self), v) != 0) { Py_DECREF(v); Py_DECREF(it); return -1; @@ -808,16 +808,16 @@ array_do_extend(arrayobject *self, PyObject *bb) "can only extend with array of same kind"); return -1; } - size = Py_Size(self) + Py_Size(b); + size = Py_SIZE(self) + Py_SIZE(b); PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize); if (self->ob_item == NULL) { PyObject_Del(self); PyErr_NoMemory(); return -1; } - memcpy(self->ob_item + Py_Size(self)*self->ob_descr->itemsize, - b->ob_item, Py_Size(b)*b->ob_descr->itemsize); - Py_Size(self) = size; + memcpy(self->ob_item + Py_SIZE(self)*self->ob_descr->itemsize, + b->ob_item, Py_SIZE(b)*b->ob_descr->itemsize); + Py_SIZE(self) = size; self->allocated = size; return 0; @@ -830,7 +830,7 @@ array_inplace_concat(arrayobject *self, PyObject *bb) if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only extend array with array (not \"%.200s\")", - Py_Type(bb)->tp_name); + Py_TYPE(bb)->tp_name); return NULL; } if (array_do_extend(self, bb) == -1) @@ -845,15 +845,15 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n) char *items, *p; Py_ssize_t size, i; - if (Py_Size(self) > 0) { + if (Py_SIZE(self) > 0) { if (n < 0) n = 0; items = self->ob_item; - size = Py_Size(self) * self->ob_descr->itemsize; + size = Py_SIZE(self) * self->ob_descr->itemsize; if (n == 0) { PyMem_FREE(items); self->ob_item = NULL; - Py_Size(self) = 0; + Py_SIZE(self) = 0; self->allocated = 0; } else { @@ -866,8 +866,8 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n) memcpy(p, items, size); } self->ob_item = items; - Py_Size(self) *= n; - self->allocated = Py_Size(self); + Py_SIZE(self) *= n; + self->allocated = Py_SIZE(self); } } Py_INCREF(self); @@ -890,7 +890,7 @@ array_count(arrayobject *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++) { PyObject *selfi = getarrayitem((PyObject *)self, i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -912,7 +912,7 @@ array_index(arrayobject *self, PyObject *v) { Py_ssize_t i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -937,7 +937,7 @@ array_contains(arrayobject *self, PyObject *v) Py_ssize_t i; int cmp; - for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(self); i++) { + for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -950,7 +950,7 @@ array_remove(arrayobject *self, PyObject *v) { int i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self,i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -980,14 +980,14 @@ array_pop(arrayobject *self, PyObject *args) PyObject *v; 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 array"); 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; } @@ -1043,7 +1043,7 @@ array_buffer_info(arrayobject *self, PyObject *unused) return NULL; PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_Size(self)))); + PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_SIZE(self)))); return retval; } @@ -1060,7 +1060,7 @@ the buffer length in bytes."); static PyObject * array_append(arrayobject *self, PyObject *v) { - return ins(self, (int) Py_Size(self), v); + return ins(self, (int) Py_SIZE(self), v); } PyDoc_STRVAR(append_doc, @@ -1079,14 +1079,14 @@ array_byteswap(arrayobject *self, PyObject *unused) case 1: break; case 2: - for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 2) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 2) { char p0 = p[0]; p[0] = p[1]; p[1] = p0; } break; case 4: - for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 4) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 4) { char p0 = p[0]; char p1 = p[1]; p[0] = p[3]; @@ -1096,7 +1096,7 @@ array_byteswap(arrayobject *self, PyObject *unused) } break; case 8: - for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 8) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 8) { char p0 = p[0]; char p1 = p[1]; char p2 = p[2]; @@ -1137,16 +1137,16 @@ array_reduce(arrayobject *array) dict = Py_None; Py_INCREF(dict); } - if (Py_Size(array) > 0) { + if (Py_SIZE(array) > 0) { result = Py_BuildValue("O(cy#)O", - Py_Type(array), + Py_TYPE(array), array->ob_descr->typecode, array->ob_item, - Py_Size(array) * array->ob_descr->itemsize, + Py_SIZE(array) * array->ob_descr->itemsize, dict); } else { result = Py_BuildValue("O(c)O", - Py_Type(array), + Py_TYPE(array), array->ob_descr->typecode, dict); } @@ -1165,9 +1165,9 @@ array_reverse(arrayobject *self, PyObject *unused) char tmp[256]; /* 8 is probably enough -- but why skimp */ assert((size_t)itemsize <= sizeof(tmp)); - if (Py_Size(self) > 1) { + if (Py_SIZE(self) > 1) { for (p = self->ob_item, - q = self->ob_item + (Py_Size(self) - 1)*itemsize; + q = self->ob_item + (Py_SIZE(self) - 1)*itemsize; p < q; p += itemsize, q -= itemsize) { /* memory areas guaranteed disjoint, so memcpy @@ -1247,14 +1247,14 @@ array. Also called as read."); static PyObject * array_tofile(arrayobject *self, PyObject *f) { - Py_ssize_t nbytes = Py_Size(self) * self->ob_descr->itemsize; + Py_ssize_t nbytes = Py_SIZE(self) * self->ob_descr->itemsize; /* Write 64K blocks at a time */ /* XXX Make the block size settable */ int BLOCKSIZE = 64*1024; Py_ssize_t nblocks = (nbytes + BLOCKSIZE - 1) / BLOCKSIZE; Py_ssize_t i; - if (Py_Size(self) == 0) + if (Py_SIZE(self) == 0) goto done; for (i = 0; i < nblocks; i++) { @@ -1299,23 +1299,23 @@ array_fromlist(arrayobject *self, PyObject *list) if (n > 0) { char *item = self->ob_item; Py_ssize_t i; - PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize); + PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = item; - Py_Size(self) += n; - self->allocated = Py_Size(self); + Py_SIZE(self) += n; + self->allocated = Py_SIZE(self); for (i = 0; i < n; i++) { PyObject *v = PyList_GetItem(list, i); if ((*self->ob_descr->setitem)(self, - Py_Size(self) - n + i, v) != 0) { - Py_Size(self) -= n; + Py_SIZE(self) - n + i, v) != 0) { + Py_SIZE(self) -= n; PyMem_RESIZE(item, char, - Py_Size(self) * itemsize); + Py_SIZE(self) * itemsize); self->ob_item = item; - self->allocated = Py_Size(self); + self->allocated = Py_SIZE(self); return NULL; } } @@ -1332,12 +1332,12 @@ Append items to array from list."); static PyObject * array_tolist(arrayobject *self, PyObject *unused) { - PyObject *list = PyList_New(Py_Size(self)); + PyObject *list = PyList_New(Py_SIZE(self)); Py_ssize_t i; if (list == NULL) return NULL; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *v = getarrayitem((PyObject *)self, i); if (v == NULL) { Py_DECREF(list); @@ -1370,15 +1370,15 @@ array_fromstring(arrayobject *self, PyObject *args) n = n / itemsize; if (n > 0) { char *item = self->ob_item; - PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize); + PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = item; - Py_Size(self) += n; - self->allocated = Py_Size(self); - memcpy(item + (Py_Size(self) - n) * itemsize, + Py_SIZE(self) += n; + self->allocated = Py_SIZE(self); + memcpy(item + (Py_SIZE(self) - n) * itemsize, str, itemsize*n); } Py_INCREF(Py_None); @@ -1396,7 +1396,7 @@ static PyObject * array_tostring(arrayobject *self, PyObject *unused) { return PyString_FromStringAndSize(self->ob_item, - Py_Size(self) * self->ob_descr->itemsize); + Py_SIZE(self) * self->ob_descr->itemsize); } PyDoc_STRVAR(tostring_doc, @@ -1425,15 +1425,15 @@ array_fromunicode(arrayobject *self, PyObject *args) } if (n > 0) { Py_UNICODE *item = (Py_UNICODE *) self->ob_item; - PyMem_RESIZE(item, Py_UNICODE, Py_Size(self) + n); + PyMem_RESIZE(item, Py_UNICODE, Py_SIZE(self) + n); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = (char *) item; - Py_Size(self) += n; - self->allocated = Py_Size(self); - memcpy(item + Py_Size(self) - n, + Py_SIZE(self) += n; + self->allocated = Py_SIZE(self); + memcpy(item + Py_SIZE(self) - n, ustr, n * sizeof(Py_UNICODE)); } @@ -1460,7 +1460,7 @@ array_tounicode(arrayobject *self, PyObject *unused) "tounicode() may only be called on unicode type arrays"); return NULL; } - return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_Size(self)); + return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_SIZE(self)); } PyDoc_STRVAR(tounicode_doc, @@ -1553,7 +1553,7 @@ array_repr(arrayobject *a) PyObject *s, *v = NULL; Py_ssize_t len; - len = Py_Size(a); + len = Py_SIZE(a); typecode = a->ob_descr->typecode; if (len == 0) { return PyUnicode_FromFormat("array('%c')", typecode); @@ -1577,7 +1577,7 @@ array_subscr(arrayobject* self, PyObject* item) return NULL; } if (i < 0) - i += Py_Size(self); + i += Py_SIZE(self); return array_item(self, i); } else if (PySlice_Check(item)) { @@ -1586,7 +1586,7 @@ array_subscr(arrayobject* self, PyObject* item) arrayobject* ar; int itemsize = self->ob_descr->itemsize; - if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self), + if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return NULL; } @@ -1640,8 +1640,8 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) if (i == -1 && PyErr_Occurred()) return -1; 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, "array assignment index out of range"); return -1; @@ -1658,7 +1658,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) } else if (PySlice_Check(item)) { if (PySlice_GetIndicesEx((PySliceObject *)item, - Py_Size(self), &start, &stop, + Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return -1; } @@ -1674,7 +1674,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) } else if (array_Check(value)) { other = (arrayobject *)value; - needed = Py_Size(other); + needed = Py_SIZE(other); if (self == other) { /* Special case "self[i:j] = self" -- copy self first */ int ret; @@ -1693,7 +1693,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) else { PyErr_Format(PyExc_TypeError, "can only assign array (not \"%.200s\") to array slice", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } itemsize = self->ob_descr->itemsize; @@ -1705,18 +1705,18 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) if (slicelength > needed) { memmove(self->ob_item + (start + needed) * itemsize, self->ob_item + stop * itemsize, - (Py_Size(self) - stop) * itemsize); - if (array_resize(self, Py_Size(self) + + (Py_SIZE(self) - stop) * itemsize); + if (array_resize(self, Py_SIZE(self) + needed - slicelength) < 0) return -1; } else if (slicelength < needed) { - if (array_resize(self, Py_Size(self) + + if (array_resize(self, Py_SIZE(self) + needed - slicelength) < 0) return -1; memmove(self->ob_item + (start + needed) * itemsize, self->ob_item + stop * itemsize, - (Py_Size(self) - start - needed) * itemsize); + (Py_SIZE(self) - start - needed) * itemsize); } if (needed > 0) memcpy(self->ob_item + start * itemsize, @@ -1736,19 +1736,19 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) cur += step, i++) { Py_ssize_t lim = step - 1; - 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) * itemsize, self->ob_item + (cur + 1) * itemsize, lim * itemsize); } cur = start + slicelength * step; - if (cur < Py_Size(self)) { + if (cur < Py_SIZE(self)) { memmove(self->ob_item + (cur-slicelength) * itemsize, self->ob_item + cur * itemsize, - (Py_Size(self) - cur) * itemsize); + (Py_SIZE(self) - cur) * itemsize); } - if (array_resize(self, Py_Size(self) - slicelength) < 0) + if (array_resize(self, Py_SIZE(self) - slicelength) < 0) return -1; return 0; } @@ -1794,14 +1794,14 @@ array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags) view->buf = (void *)self->ob_item; if (view->buf == NULL) view->buf = (void *)emptybuf; - view->len = (Py_Size(self)) * self->ob_descr->itemsize; + view->len = (Py_SIZE(self)) * self->ob_descr->itemsize; view->readonly = 0; view->ndim = 1; view->itemsize = self->ob_descr->itemsize; view->suboffsets = NULL; view->shape = NULL; if ((flags & PyBUF_ND)==PyBUF_ND) { - view->shape = &((Py_Size(self))); + view->shape = &((Py_SIZE(self))); } view->strides = NULL; if ((flags & PyBUF_STRIDES)==PyBUF_STRIDES) @@ -1935,9 +1935,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return NULL; } self->ob_item = item; - Py_Size(self) = n / sizeof(Py_UNICODE); + Py_SIZE(self) = n / sizeof(Py_UNICODE); memcpy(item, PyUnicode_AS_DATA(initial), n); - self->allocated = Py_Size(self); + self->allocated = Py_SIZE(self); } } if (it != NULL) { @@ -2108,7 +2108,7 @@ static PyObject * arrayiter_next(arrayiterobject *it) { assert(PyArrayIter_Check(it)); - if (it->index < Py_Size(it->ao)) + if (it->index < Py_SIZE(it->ao)) return (*it->getitem)(it->ao, it->index++); return NULL; } @@ -2180,7 +2180,7 @@ initarray(void) if (PyType_Ready(&Arraytype) < 0) return; - Py_Type(&PyArrayIter_Type) = &PyType_Type; + Py_TYPE(&PyArrayIter_Type) = &PyType_Type; m = Py_InitModule3("array", a_methods, module_doc); if (m == NULL) return; diff --git a/Modules/bz2module.c b/Modules/bz2module.c index 32c8106..89d35aa 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -41,7 +41,7 @@ typedef fpos_t Py_off_t; #define MODE_READ_EOF 2 #define MODE_WRITE 3 -#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type) +#define BZ2FileObject_Check(v) (Py_TYPE(v) == &BZ2File_Type) #ifdef BZ_CONFIG_ERROR @@ -1240,7 +1240,7 @@ BZ2File_dealloc(BZ2FileObject *self) Util_DropReadAhead(self); if (self->rawfp != NULL) fclose(self->rawfp); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } /* This is a hacked version of Python's fileobject.c:file_getiter(). */ @@ -1552,7 +1552,7 @@ BZ2Comp_dealloc(BZ2CompObject *self) PyThread_free_lock(self->lock); #endif BZ2_bzCompressEnd(&self->bzs); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } @@ -1777,7 +1777,7 @@ BZ2Decomp_dealloc(BZ2DecompObject *self) #endif Py_XDECREF(self->unused_data); BZ2_bzDecompressEnd(&self->bzs); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } @@ -2031,9 +2031,9 @@ initbz2(void) { PyObject *m; - Py_Type(&BZ2File_Type) = &PyType_Type; - Py_Type(&BZ2Comp_Type) = &PyType_Type; - Py_Type(&BZ2Decomp_Type) = &PyType_Type; + Py_TYPE(&BZ2File_Type) = &PyType_Type; + Py_TYPE(&BZ2Comp_Type) = &PyType_Type; + Py_TYPE(&BZ2Decomp_Type) = &PyType_Type; m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); if (m == NULL) diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c index 79834f9..1251c1d 100644 --- a/Modules/cStringIO.c +++ b/Modules/cStringIO.c @@ -738,8 +738,8 @@ initcStringIO(void) { d = PyModule_GetDict(m); /* Export C API */ - Py_Type(&Itype)=&PyType_Type; - Py_Type(&Otype)=&PyType_Type; + Py_TYPE(&Itype)=&PyType_Type; + Py_TYPE(&Otype)=&PyType_Type; if (PyType_Ready(&Otype) < 0) return; if (PyType_Ready(&Itype) < 0) return; PyDict_SetItemString(d,"cStringIO_CAPI", diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 5672fc33..4371db4 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -953,7 +953,7 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self) { PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyTypeObject MultibyteIncrementalEncoder_Type = { @@ -1153,7 +1153,7 @@ mbidecoder_dealloc(MultibyteIncrementalDecoderObject *self) { PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyTypeObject MultibyteIncrementalDecoder_Type = { @@ -1479,7 +1479,7 @@ mbstreamreader_dealloc(MultibyteStreamReaderObject *self) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_DECREF(self->stream); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyTypeObject MultibyteStreamReader_Type = { @@ -1682,7 +1682,7 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self) PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_DECREF(self->stream); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static struct PyMethodDef mbstreamwriter_methods[] = { diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 8eb7e04..1e30f7e 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -764,7 +764,7 @@ check_tzinfo_subclass(PyObject *p) PyErr_Format(PyExc_TypeError, "tzinfo argument must be None or of a tzinfo subclass, " "not type '%s'", - Py_Type(p)->tp_name); + Py_TYPE(p)->tp_name); return -1; } @@ -855,7 +855,7 @@ call_utc_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg, PyErr_Format(PyExc_TypeError, "tzinfo.%s() must return None or " "timedelta, not '%s'", - name, Py_Type(u)->tp_name); + name, Py_TYPE(u)->tp_name); } Py_DECREF(u); @@ -950,7 +950,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg) if (!PyUnicode_Check(result)) { PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must " "return None or a string, not '%s'", - Py_Type(result)->tp_name); + Py_TYPE(result)->tp_name); Py_DECREF(result); result = NULL; } @@ -1293,7 +1293,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, assert(PyUnicode_Check(Zreplacement)); ptoappend = PyUnicode_AsStringAndSize(Zreplacement, &ntoappend); - ntoappend = Py_Size(Zreplacement); + ntoappend = Py_SIZE(Zreplacement); } else { /* percent followed by neither z nor Z */ @@ -1425,7 +1425,7 @@ cmperror(PyObject *a, PyObject *b) { PyErr_Format(PyExc_TypeError, "can't compare %s to %s", - Py_Type(a)->tp_name, Py_Type(b)->tp_name); + Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name); return NULL; } @@ -1869,7 +1869,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor, PyErr_Format(PyExc_TypeError, "unsupported type for timedelta %s component: %s", - tag, Py_Type(num)->tp_name); + tag, Py_TYPE(num)->tp_name); return NULL; } @@ -1973,18 +1973,18 @@ delta_repr(PyDateTime_Delta *self) { if (GET_TD_MICROSECONDS(self) != 0) return PyUnicode_FromFormat("%s(%d, %d, %d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_TD_DAYS(self), GET_TD_SECONDS(self), GET_TD_MICROSECONDS(self)); if (GET_TD_SECONDS(self) != 0) return PyUnicode_FromFormat("%s(%d, %d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_TD_DAYS(self), GET_TD_SECONDS(self)); return PyUnicode_FromFormat("%s(%d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_TD_DAYS(self)); } @@ -2031,7 +2031,7 @@ delta_getstate(PyDateTime_Delta *self) static PyObject * delta_reduce(PyDateTime_Delta* self) { - return Py_BuildValue("ON", Py_Type(self), delta_getstate(self)); + return Py_BuildValue("ON", Py_TYPE(self), delta_getstate(self)); } #define OFFSET(field) offsetof(PyDateTime_Delta, field) @@ -2385,7 +2385,7 @@ static PyObject * date_repr(PyDateTime_Date *self) { return PyUnicode_FromFormat("%s(%d, %d, %d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); } @@ -2522,7 +2522,7 @@ date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw) tuple = Py_BuildValue("iii", year, month, day); if (tuple == NULL) return NULL; - clone = date_new(Py_Type(self), tuple, NULL); + clone = date_new(Py_TYPE(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -2590,7 +2590,7 @@ date_getstate(PyDateTime_Date *self) static PyObject * date_reduce(PyDateTime_Date *self, PyObject *arg) { - return Py_BuildValue("(ON)", Py_Type(self), date_getstate(self)); + return Py_BuildValue("(ON)", Py_TYPE(self), date_getstate(self)); } static PyMethodDef date_methods[] = { @@ -2893,10 +2893,10 @@ tzinfo_reduce(PyObject *self) if (state == Py_None) { Py_DECREF(state); - return Py_BuildValue("(ON)", Py_Type(self), args); + return Py_BuildValue("(ON)", Py_TYPE(self), args); } else - return Py_BuildValue("(ONN)", Py_Type(self), args, state); + return Py_BuildValue("(ONN)", Py_TYPE(self), args, state); } static PyMethodDef tzinfo_methods[] = { @@ -3089,7 +3089,7 @@ time_dealloc(PyDateTime_Time *self) if (HASTZINFO(self)) { Py_XDECREF(self->tzinfo); } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } /* @@ -3122,7 +3122,7 @@ time_tzname(PyDateTime_Time *self, PyObject *unused) { static PyObject * time_repr(PyDateTime_Time *self) { - const char *type_name = Py_Type(self)->tp_name; + const char *type_name = Py_TYPE(self)->tp_name; int h = TIME_GET_HOUR(self); int m = TIME_GET_MINUTE(self); int s = TIME_GET_SECOND(self); @@ -3346,7 +3346,7 @@ time_replace(PyDateTime_Time *self, PyObject *args, PyObject *kw) tuple = Py_BuildValue("iiiiO", hh, mm, ss, us, tzinfo); if (tuple == NULL) return NULL; - clone = time_new(Py_Type(self), tuple, NULL); + clone = time_new(Py_TYPE(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -3400,7 +3400,7 @@ time_getstate(PyDateTime_Time *self) static PyObject * time_reduce(PyDateTime_Time *self, PyObject *arg) { - return Py_BuildValue("(ON)", Py_Type(self), time_getstate(self)); + return Py_BuildValue("(ON)", Py_TYPE(self), time_getstate(self)); } static PyMethodDef time_methods[] = { @@ -3897,7 +3897,7 @@ datetime_dealloc(PyDateTime_DateTime *self) if (HASTZINFO(self)) { Py_XDECREF(self->tzinfo); } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } /* @@ -4045,7 +4045,7 @@ datetime_subtract(PyObject *left, PyObject *right) static PyObject * datetime_repr(PyDateTime_DateTime *self) { - const char *type_name = Py_Type(self)->tp_name; + const char *type_name = Py_TYPE(self)->tp_name; PyObject *baserepr; if (DATE_GET_MICROSECOND(self)) { @@ -4262,7 +4262,7 @@ datetime_replace(PyDateTime_DateTime *self, PyObject *args, PyObject *kw) tuple = Py_BuildValue("iiiiiiiO", y, m, d, hh, mm, ss, us, tzinfo); if (tuple == NULL) return NULL; - clone = datetime_new(Py_Type(self), tuple, NULL); + clone = datetime_new(Py_TYPE(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -4450,7 +4450,7 @@ datetime_getstate(PyDateTime_DateTime *self) static PyObject * datetime_reduce(PyDateTime_DateTime *self, PyObject *arg) { - return Py_BuildValue("(ON)", Py_Type(self), datetime_getstate(self)); + return Py_BuildValue("(ON)", Py_TYPE(self), datetime_getstate(self)); } static PyMethodDef datetime_methods[] = { diff --git a/Modules/dbmmodule.c b/Modules/dbmmodule.c index 6b05fad..7129c8e 100644 --- a/Modules/dbmmodule.c +++ b/Modules/dbmmodule.c @@ -36,7 +36,7 @@ typedef struct { static PyTypeObject Dbmtype; -#define is_dbmobject(v) (Py_Type(v) == &Dbmtype) +#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype) #define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ { PyErr_SetString(DbmError, "DBM object has already been closed"); \ return NULL; } diff --git a/Modules/dlmodule.c b/Modules/dlmodule.c index aaca4cf..04587f6 100644 --- a/Modules/dlmodule.c +++ b/Modules/dlmodule.c @@ -62,7 +62,7 @@ dl_sym(dlobject *xp, PyObject *args) name = PyUnicode_AsString(args); } else { PyErr_Format(PyExc_TypeError, "expected string, found %.200s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return NULL; } func = dlsym(xp->dl_handle, name); @@ -238,7 +238,7 @@ initdl(void) PyObject *m, *d, *x; /* Initialize object type */ - Py_Type(&Dltype) = &PyType_Type; + Py_TYPE(&Dltype) = &PyType_Type; /* Create the module and add the functions */ m = Py_InitModule("dl", dl_methods); diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 5fd8923..37fcc51 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -235,7 +235,7 @@ update_refs(PyGC_Head *containers) PyGC_Head *gc = containers->gc.gc_next; for (; gc != containers; gc = gc->gc.gc_next) { assert(gc->gc.gc_refs == GC_REACHABLE); - gc->gc.gc_refs = Py_Refcnt(FROM_GC(gc)); + gc->gc.gc_refs = Py_REFCNT(FROM_GC(gc)); /* Python's cyclic gc should never see an incoming refcount * of 0: if something decref'ed to 0, it should have been * deallocated immediately at that time. @@ -287,7 +287,7 @@ subtract_refs(PyGC_Head *containers) traverseproc traverse; PyGC_Head *gc = containers->gc.gc_next; for (; gc != containers; gc=gc->gc.gc_next) { - traverse = Py_Type(FROM_GC(gc))->tp_traverse; + traverse = Py_TYPE(FROM_GC(gc))->tp_traverse; (void) traverse(FROM_GC(gc), (visitproc)visit_decref, NULL); @@ -372,7 +372,7 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable) * the next object to visit. */ PyObject *op = FROM_GC(gc); - traverseproc traverse = Py_Type(op)->tp_traverse; + traverseproc traverse = Py_TYPE(op)->tp_traverse; assert(gc->gc.gc_refs > 0); gc->gc.gc_refs = GC_REACHABLE; (void) traverse(op, @@ -456,7 +456,7 @@ move_finalizer_reachable(PyGC_Head *finalizers) PyGC_Head *gc = finalizers->gc.gc_next; for (; gc != finalizers; gc = gc->gc.gc_next) { /* Note that the finalizers list may grow during this. */ - traverse = Py_Type(FROM_GC(gc))->tp_traverse; + traverse = Py_TYPE(FROM_GC(gc))->tp_traverse; (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); @@ -501,7 +501,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old) assert(IS_TENTATIVELY_UNREACHABLE(op)); next = gc->gc.gc_next; - if (! PyType_SUPPORTS_WEAKREFS(Py_Type(op))) + if (! PyType_SUPPORTS_WEAKREFS(Py_TYPE(op))) continue; /* It supports weakrefs. Does it have any? */ @@ -620,7 +620,7 @@ static void debug_cycle(char *msg, PyObject *op) { PySys_WriteStderr("gc: %.100s <%.100s %p>\n", - msg, Py_Type(op)->tp_name, op); + msg, Py_TYPE(op)->tp_name, op); } /* Handle uncollectable garbage (cycles with finalizers, and stuff reachable @@ -673,7 +673,7 @@ delete_garbage(PyGC_Head *collectable, PyGC_Head *old) PyList_Append(garbage, op); } else { - if ((clear = Py_Type(op)->tp_clear) != NULL) { + if ((clear = Py_TYPE(op)->tp_clear) != NULL) { Py_INCREF(op); clear(op); Py_DECREF(op); @@ -1042,7 +1042,7 @@ gc_referrers_for(PyObject *objs, PyGC_Head *list, PyObject *resultlist) traverseproc traverse; for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) { obj = FROM_GC(gc); - traverse = Py_Type(obj)->tp_traverse; + traverse = Py_TYPE(obj)->tp_traverse; if (obj == objs || obj == resultlist) continue; if (traverse(obj, (visitproc)referrersvisit, objs)) { @@ -1099,7 +1099,7 @@ gc_get_referents(PyObject *self, PyObject *args) if (! PyObject_IS_GC(obj)) continue; - traverse = Py_Type(obj)->tp_traverse; + traverse = Py_TYPE(obj)->tp_traverse; if (! traverse) continue; if (traverse(obj, (visitproc)referentsvisit, result)) { @@ -1320,13 +1320,13 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems) PyVarObject * _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems) { - const size_t basicsize = _PyObject_VAR_SIZE(Py_Type(op), nitems); + const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems); PyGC_Head *g = AS_GC(op); g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize); if (g == NULL) return (PyVarObject *)PyErr_NoMemory(); op = (PyVarObject *) FROM_GC(g); - Py_Size(op) = nitems; + Py_SIZE(op) = nitems; return op; } diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c index 86f98c0..9e1b01d 100644 --- a/Modules/gdbmmodule.c +++ b/Modules/gdbmmodule.c @@ -36,7 +36,7 @@ typedef struct { static PyTypeObject Dbmtype; -#define is_dbmobject(v) (Py_Type(v) == &Dbmtype) +#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype) #define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ { PyErr_SetString(DbmError, "GDBM object has already been closed"); \ return NULL; } diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index fc99bd5..132acc5 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -59,7 +59,7 @@ groupby_dealloc(groupbyobject *gbo) Py_XDECREF(gbo->tgtkey); Py_XDECREF(gbo->currkey); Py_XDECREF(gbo->currvalue); - Py_Type(gbo)->tp_free(gbo); + Py_TYPE(gbo)->tp_free(gbo); } static int @@ -714,7 +714,7 @@ cycle_dealloc(cycleobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->saved); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -857,7 +857,7 @@ dropwhile_dealloc(dropwhileobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -877,7 +877,7 @@ dropwhile_next(dropwhileobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -1000,7 +1000,7 @@ takewhile_dealloc(takewhileobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1022,7 +1022,7 @@ takewhile_next(takewhileobject *lz) return NULL; assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) return NULL; @@ -1190,7 +1190,7 @@ islice_dealloc(isliceobject *lz) { PyObject_GC_UnTrack(lz); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1209,7 +1209,7 @@ islice_next(isliceobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; while (lz->cnt < lz->next) { item = iternext(it); if (item == NULL) @@ -1333,7 +1333,7 @@ starmap_dealloc(starmapobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1352,7 +1352,7 @@ starmap_next(starmapobject *lz) PyObject *it = lz->it; assert(PyIter_Check(it)); - args = (*Py_Type(it)->tp_iternext)(it); + args = (*Py_TYPE(it)->tp_iternext)(it); if (args == NULL) return NULL; if (!PyTuple_CheckExact(args)) { @@ -1478,7 +1478,7 @@ imap_dealloc(imapobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->iters); Py_XDECREF(lz->func); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1656,7 +1656,7 @@ chain_dealloc(chainobject *lz) { PyObject_GC_UnTrack(lz); Py_XDECREF(lz->ittuple); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1787,7 +1787,7 @@ ifilter_dealloc(ifilterobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1807,7 +1807,7 @@ ifilter_next(ifilterobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -1931,7 +1931,7 @@ ifilterfalse_dealloc(ifilterfalseobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1951,7 +1951,7 @@ ifilterfalse_next(ifilterfalseobject *lz) PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -2253,7 +2253,7 @@ izip_dealloc(izipobject *lz) PyObject_GC_UnTrack(lz); Py_XDECREF(lz->ittuple); Py_XDECREF(lz->result); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -2276,12 +2276,12 @@ izip_next(izipobject *lz) if (tuplesize == 0) return NULL; - if (Py_Refcnt(result) == 1) { + if (Py_REFCNT(result) == 1) { Py_INCREF(result); for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { Py_DECREF(result); return NULL; @@ -2297,7 +2297,7 @@ izip_next(izipobject *lz) for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { Py_DECREF(result); return NULL; @@ -2403,7 +2403,7 @@ repeat_dealloc(repeatobject *ro) { PyObject_GC_UnTrack(ro); Py_XDECREF(ro->element); - Py_Type(ro)->tp_free(ro); + Py_TYPE(ro)->tp_free(ro); } static int @@ -2588,7 +2588,7 @@ izip_longest_dealloc(iziplongestobject *lz) Py_XDECREF(lz->ittuple); Py_XDECREF(lz->result); Py_XDECREF(lz->fillvalue); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -2614,7 +2614,7 @@ izip_longest_next(iziplongestobject *lz) return NULL; if (lz->numactive == 0) return NULL; - if (Py_Refcnt(result) == 1) { + if (Py_REFCNT(result) == 1) { Py_INCREF(result); for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); @@ -2623,7 +2623,7 @@ izip_longest_next(iziplongestobject *lz) item = lz->fillvalue; } else { assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { lz->numactive -= 1; if (lz->numactive == 0) { @@ -2652,7 +2652,7 @@ izip_longest_next(iziplongestobject *lz) item = lz->fillvalue; } else { assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { lz->numactive -= 1; if (lz->numactive == 0) { @@ -2783,7 +2783,7 @@ inititertools(void) NULL }; - Py_Type(&teedataobject_type) = &PyType_Type; + Py_TYPE(&teedataobject_type) = &PyType_Type; m = Py_InitModule3("itertools", module_methods, module_doc); if (m == NULL) return; diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 864df23..edf5e9b 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -118,7 +118,7 @@ static PyObject * math_ceil(PyObject *self, PyObject *number) { return NULL; } - method = _PyType_Lookup(Py_Type(number), ceil_str); + method = _PyType_Lookup(Py_TYPE(number), ceil_str); if (method == NULL) return math_1(number, ceil); else @@ -148,7 +148,7 @@ static PyObject * math_floor(PyObject *self, PyObject *number) { return NULL; } - method = _PyType_Lookup(Py_Type(number), floor_str); + method = _PyType_Lookup(Py_TYPE(number), floor_str); if (method == NULL) return math_1(number, floor); else diff --git a/Modules/md5module.c b/Modules/md5module.c index 567383a..833eb81 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -340,7 +340,7 @@ MD5_copy(MD5object *self, PyObject *unused) { MD5object *newobj; - if (Py_Type(self) == &MD5type) { + if (Py_TYPE(self) == &MD5type) { if ( (newobj = newMD5object())==NULL) return NULL; } else { @@ -552,7 +552,7 @@ init_md5(void) { PyObject *m; - Py_Type(&MD5type) = &PyType_Type; + Py_TYPE(&MD5type) = &PyType_Type; if (PyType_Ready(&MD5type) < 0) return; m = Py_InitModule("_md5", MD5_functions); diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 77aa643..84f909e 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1253,7 +1253,7 @@ PyMODINIT_FUNC PyObject *dict, *module; /* Patch the object type */ - Py_Type(&mmap_object_type) = &PyType_Type; + Py_TYPE(&mmap_object_type) = &PyType_Type; module = Py_InitModule("mmap", mmap_functions); if (module == NULL) diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 87f9e2e..4c00203 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -694,7 +694,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num) PyErr_Format(parser_error, "second item in terminal node must be a string," " found %s", - Py_Type(temp)->tp_name); + Py_TYPE(temp)->tp_name); Py_DECREF(temp); Py_DECREF(elem); return 0; @@ -708,7 +708,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num) PyErr_Format(parser_error, "third item in terminal node must be an" " integer, found %s", - Py_Type(temp)->tp_name); + Py_TYPE(temp)->tp_name); Py_DECREF(o); Py_DECREF(temp); Py_DECREF(elem); @@ -3056,7 +3056,7 @@ initparser(void) { PyObject *module, *copyreg; - Py_Type(&PyST_Type) = &PyType_Type; + Py_TYPE(&PyST_Type) = &PyType_Type; module = Py_InitModule("parser", parser_functions); if (module == NULL) return; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 92a8b28..12bdde0 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2706,7 +2706,7 @@ extract_time(PyObject *t, long* sec, long* usec) long intval; if (PyFloat_Check(t)) { double tval = PyFloat_AsDouble(t); - PyObject *intobj = Py_Type(t)->tp_as_number->nb_int(t); + PyObject *intobj = Py_TYPE(t)->tp_as_number->nb_int(t); if (!intobj) return -1; intval = PyLong_AsLong(intobj); diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 5da00a2..ab917f0 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -871,10 +871,10 @@ readinst(char *buf, int buf_size, PyObject *meth) else { PyErr_Format(PyExc_TypeError, "read() did not return a bytes object (type=%.400s)", - Py_Type(str)->tp_name); + Py_TYPE(str)->tp_name); goto finally; } - len = Py_Size(str); + len = Py_SIZE(str); if (len > buf_size) { PyErr_Format(PyExc_ValueError, "read() returned too much data: " @@ -1738,7 +1738,7 @@ MODULE_INITFUNC(void) if (modelmod_name == NULL) return; - Py_Type(&Xmlparsetype) = &PyType_Type; + Py_TYPE(&Xmlparsetype) = &PyType_Type; /* Create the module and add the functions */ m = Py_InitModule3(MODULE_NAME, pyexpat_methods, diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 4925b9d..c4ebecc 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -701,7 +701,7 @@ initselect(void) #else { #endif - Py_Type(&poll_Type) = &PyType_Type; + Py_TYPE(&poll_Type) = &PyType_Type; PyModule_AddIntConstant(m, "POLLIN", POLLIN); PyModule_AddIntConstant(m, "POLLPRI", POLLPRI); PyModule_AddIntConstant(m, "POLLOUT", POLLOUT); diff --git a/Modules/sha1module.c b/Modules/sha1module.c index aeba185..9b4d8e5 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -316,7 +316,7 @@ SHA1_copy(SHA1object *self, PyObject *unused) { SHA1object *newobj; - if (Py_Type(self) == &SHA1type) { + if (Py_TYPE(self) == &SHA1type) { if ( (newobj = newSHA1object())==NULL) return NULL; } else { @@ -528,7 +528,7 @@ init_sha1(void) { PyObject *m; - Py_Type(&SHA1type) = &PyType_Type; + Py_TYPE(&SHA1type) = &PyType_Type; if (PyType_Ready(&SHA1type) < 0) return; m = Py_InitModule("_sha1", SHA1_functions); diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 928d1d4..f310134 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -409,7 +409,7 @@ SHA256_copy(SHAobject *self, PyObject *unused) { SHAobject *newobj; - if (Py_Type(self) == &SHA256type) { + if (Py_TYPE(self) == &SHA256type) { if ( (newobj = newSHA256object())==NULL) return NULL; } else { @@ -687,10 +687,10 @@ init_sha256(void) { PyObject *m; - Py_Type(&SHA224type) = &PyType_Type; + Py_TYPE(&SHA224type) = &PyType_Type; if (PyType_Ready(&SHA224type) < 0) return; - Py_Type(&SHA256type) = &PyType_Type; + Py_TYPE(&SHA256type) = &PyType_Type; if (PyType_Ready(&SHA256type) < 0) return; m = Py_InitModule("_sha256", SHA_functions); diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 761d44a..3e32132 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -753,10 +753,10 @@ init_sha512(void) { PyObject *m; - Py_Type(&SHA384type) = &PyType_Type; + Py_TYPE(&SHA384type) = &PyType_Type; if (PyType_Ready(&SHA384type) < 0) return; - Py_Type(&SHA512type) = &PyType_Type; + Py_TYPE(&SHA512type) = &PyType_Type; if (PyType_Ready(&SHA512type) < 0) return; m = Py_InitModule("_sha512", SHA_functions); diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index ddffd23..3909cbc 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1135,7 +1135,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_NETLINK address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &pid, &groups)) @@ -1158,7 +1158,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_INET address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", @@ -1188,7 +1188,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_INET6 address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "eti|ii", @@ -1310,7 +1310,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, PyExc_TypeError, "getsockaddrarg: " "AF_PACKET address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "si|iiy#", &interfaceName, @@ -2580,7 +2580,7 @@ sock_dealloc(PySocketSockObject *s) { if (s->sock_fd != -1) (void) SOCKETCLOSE(s->sock_fd); - Py_Type(s)->tp_free((PyObject *)s); + Py_TYPE(s)->tp_free((PyObject *)s); } @@ -3275,7 +3275,7 @@ socket_ntohl(PyObject *self, PyObject *arg) else return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); if (x == (unsigned long) -1 && PyErr_Occurred()) return NULL; return PyLong_FromUnsignedLong(ntohl(x)); @@ -3334,7 +3334,7 @@ socket_htonl(PyObject *self, PyObject *arg) else return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); return PyLong_FromUnsignedLong(htonl((unsigned long)x)); } @@ -3962,7 +3962,7 @@ init_socket(void) if (!os_init()) return; - Py_Type(&sock_type) = &PyType_Type; + Py_TYPE(&sock_type) = &PyType_Type; m = Py_InitModule3(PySocket_MODULE_NAME, socket_methods, socket_doc); diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c index d948154..b8b7fb5 100644 --- a/Modules/threadmodule.c +++ b/Modules/threadmodule.c @@ -250,7 +250,7 @@ local_dealloc(localobject *self) } local_clear(self); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } static PyObject * @@ -282,8 +282,8 @@ _ldict(localobject *self) Py_INCREF(ldict); self->dict = ldict; /* still borrowed */ - if (Py_Type(self)->tp_init != PyBaseObject_Type.tp_init && - Py_Type(self)->tp_init((PyObject*)self, + if (Py_TYPE(self)->tp_init != PyBaseObject_Type.tp_init && + Py_TYPE(self)->tp_init((PyObject*)self, self->args, self->kw) < 0) { /* we need to get rid of ldict from thread so we create a new one the next time we do an attr @@ -386,7 +386,7 @@ local_getattro(localobject *self, PyObject *name) if (ldict == NULL) return NULL; - if (Py_Type(self) != &localtype) + if (Py_TYPE(self) != &localtype) /* use generic lookup for subtypes */ return PyObject_GenericGetAttr((PyObject *)self, name); diff --git a/Modules/timemodule.c b/Modules/timemodule.c index c64a356..36a723a 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -365,7 +365,7 @@ gettmarg(PyObject *args, struct tm *p) t = args; Py_INCREF(t); } - else if (Py_Type(args) == &StructTimeType) { + else if (Py_TYPE(args) == &StructTimeType) { t = structtime_totuple(args); } else { diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c index 060642b..b2c8733 100644 --- a/Modules/unicodedata.c +++ b/Modules/unicodedata.c @@ -1187,7 +1187,7 @@ initunicodedata(void) { PyObject *m, *v; - Py_Type(&UCD_Type) = &PyType_Type; + Py_TYPE(&UCD_Type) = &PyType_Type; m = Py_InitModule3( "unicodedata", unicodedata_functions, unicodedata_docstring); diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c index 5c371fb..18dcf5c 100644 --- a/Modules/xxmodule.c +++ b/Modules/xxmodule.c @@ -25,7 +25,7 @@ typedef struct { static PyTypeObject Xxo_Type; -#define XxoObject_Check(v) (Py_Type(v) == &Xxo_Type) +#define XxoObject_Check(v) (Py_TYPE(v) == &Xxo_Type) static XxoObject * newXxoObject(PyObject *arg) diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 5f41e8d..08322b6 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -171,7 +171,7 @@ zipimporter_dealloc(ZipImporter *self) Py_XDECREF(self->archive); Py_XDECREF(self->prefix); Py_XDECREF(self->files); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 55e892a..441d61d 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -1012,8 +1012,8 @@ PyMODINIT_FUNC PyInit_zlib(void) { PyObject *m, *ver; - Py_Type(&Comptype) = &PyType_Type; - Py_Type(&Decomptype) = &PyType_Type; + Py_TYPE(&Comptype) = &PyType_Type; + Py_TYPE(&Decomptype) = &PyType_Type; m = Py_InitModule4("zlib", zlib_methods, zlib_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); |