mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
This commit is contained in:
parent
d586559c31
commit
e93237dfcc
108 changed files with 916 additions and 908 deletions
|
@ -205,16 +205,16 @@ staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLoc
|
|||
|
||||
#ifndef Py_Type
|
||||
/* for compatibility with Python 2.5 and earlier */
|
||||
#define Py_Type(ob) (((PyObject*)(ob))->ob_type)
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
@ -383,7 +383,7 @@ make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags)
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"String or Integer object expected for key, %s found",
|
||||
Py_Type(keyobj)->tp_name);
|
||||
Py_TYPE(keyobj)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5535,13 +5535,13 @@ DL_EXPORT(void) 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
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -980,7 +980,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 *
|
||||
|
@ -1188,7 +1188,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);
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1231,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);
|
||||
|
|
|
@ -125,7 +125,7 @@ typedef struct {
|
|||
|
||||
staticforward 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
|
||||
|
@ -310,7 +310,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[] = {
|
||||
|
|
|
@ -333,7 +333,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);
|
||||
|
@ -349,7 +349,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;
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
|
|||
char *ptr;
|
||||
Py_ssize_t size;
|
||||
if (PyBuffer_Check(value)) {
|
||||
size = Py_Type(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
|
||||
size = Py_TYPE(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
|
||||
if (size < 0)
|
||||
return -1;
|
||||
} else if (-1 == PyString_AsStringAndSize(value, &ptr, &size)) {
|
||||
|
@ -803,7 +803,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
|
|||
} else if (!PyString_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"string expected instead of %s instance",
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
} else
|
||||
Py_INCREF(value);
|
||||
|
@ -863,7 +863,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);
|
||||
|
@ -2081,7 +2081,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[] = {
|
||||
|
@ -2354,7 +2354,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;
|
||||
}
|
||||
}
|
||||
|
@ -2385,7 +2385,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;
|
||||
}
|
||||
|
@ -2404,7 +2404,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;
|
||||
}
|
||||
|
@ -2665,7 +2665,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;
|
||||
}
|
||||
|
||||
|
@ -3451,7 +3451,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 *
|
||||
|
@ -3461,11 +3461,11 @@ CFuncPtr_repr(CFuncPtrObject *self)
|
|||
if (self->index)
|
||||
return PyString_FromFormat("<COM method offset %d: %s at %p>",
|
||||
self->index - 0x1000,
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
self);
|
||||
#endif
|
||||
return PyString_FromFormat("<%s object at %p>",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
self);
|
||||
}
|
||||
|
||||
|
@ -4195,7 +4195,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;
|
||||
}
|
||||
|
@ -4260,9 +4260,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 PyString_FromFormat("<%s object at %p>",
|
||||
Py_Type(self)->tp_name, self);
|
||||
Py_TYPE(self)->tp_name, self);
|
||||
}
|
||||
|
||||
if (format == NULL) {
|
||||
|
@ -4275,7 +4275,7 @@ Simple_repr(CDataObject *self)
|
|||
if (val == NULL)
|
||||
return NULL;
|
||||
|
||||
name = PyString_FromString(Py_Type(self)->tp_name);
|
||||
name = PyString_FromString(Py_TYPE(self)->tp_name);
|
||||
if (name == NULL) {
|
||||
Py_DECREF(val);
|
||||
return NULL;
|
||||
|
@ -4446,7 +4446,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;
|
||||
}
|
||||
|
||||
|
@ -4876,7 +4876,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;
|
||||
}
|
||||
|
||||
|
@ -5003,37 +5003,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;
|
||||
|
|
|
@ -1180,7 +1180,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;
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1420,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,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);
|
||||
|
@ -214,7 +214,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;
|
||||
|
@ -262,7 +262,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. */
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -2656,7 +2656,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;
|
||||
|
|
|
@ -269,7 +269,7 @@ typedef struct {
|
|||
|
||||
staticforward 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 */
|
||||
|
@ -1207,7 +1207,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;
|
||||
}
|
||||
|
@ -1440,7 +1440,7 @@ typedef struct {
|
|||
|
||||
staticforward PyTypeObject TreeBuilder_Type;
|
||||
|
||||
#define TreeBuilder_CheckExact(op) (Py_Type(op) == &TreeBuilder_Type)
|
||||
#define TreeBuilder_CheckExact(op) (Py_TYPE(op) == &TreeBuilder_Type)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* constructor and destructor */
|
||||
|
@ -1607,7 +1607,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... */
|
||||
|
@ -2623,9 +2623,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);
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -463,7 +463,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;
|
||||
|
||||
|
|
|
@ -1611,8 +1611,8 @@ init_hotshot(void)
|
|||
{
|
||||
PyObject *module;
|
||||
|
||||
Py_Type(&LogReaderType) = &PyType_Type;
|
||||
Py_Type(&ProfilerType) = &PyType_Type;
|
||||
Py_TYPE(&LogReaderType) = &PyType_Type;
|
||||
Py_TYPE(&ProfilerType) = &PyType_Type;
|
||||
module = Py_InitModule("_hotshot", functions);
|
||||
if (module != NULL) {
|
||||
char *s = get_version_string();
|
||||
|
|
|
@ -120,7 +120,7 @@ typedef struct {
|
|||
staticforward 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 = PyString_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
|
||||
|
|
|
@ -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 (!PyInt_Check(n) && !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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -313,7 +313,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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1689,7 +1689,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
|
|||
#endif
|
||||
|
||||
/* get pointer to string buffer */
|
||||
buffer = Py_Type(string)->tp_as_buffer;
|
||||
buffer = Py_TYPE(string)->tp_as_buffer;
|
||||
if (!buffer || !buffer->bf_getreadbuffer || !buffer->bf_getsegcount ||
|
||||
buffer->bf_getsegcount(string, NULL) != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected string or buffer");
|
||||
|
|
|
@ -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,
|
||||
|
@ -1365,7 +1365,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg)
|
|||
if (!PyString_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(PyString_AS_STRING(arg));
|
||||
if (bytes == -1) {
|
||||
PyErr_SetString(PySSLErrorObject,
|
||||
|
@ -1480,7 +1480,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)
|
||||
|
|
|
@ -72,7 +72,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 */
|
||||
|
@ -133,7 +133,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)
|
||||
|
@ -1487,7 +1487,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 *
|
||||
|
@ -1856,7 +1856,7 @@ init_struct(void)
|
|||
if (m == NULL)
|
||||
return;
|
||||
|
||||
Py_Type(&PyStructType) = &PyType_Type;
|
||||
Py_TYPE(&PyStructType) = &PyType_Type;
|
||||
if (PyType_Ready(&PyStructType) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -889,7 +889,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);
|
||||
|
||||
|
|
|
@ -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)))
|
||||
|
||||
|
||||
|
||||
|
@ -3105,7 +3105,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();
|
||||
|
@ -3133,10 +3133,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
|
||||
|
|
|
@ -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 = PyInt_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);
|
||||
|
||||
|
|
|
@ -39,7 +39,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)
|
||||
|
@ -53,9 +53,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;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,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 */
|
||||
|
@ -84,7 +84,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;
|
||||
}
|
||||
|
@ -432,7 +432,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;
|
||||
}
|
||||
|
@ -455,7 +455,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);
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,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;
|
||||
|
@ -498,7 +498,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 *
|
||||
|
@ -518,7 +518,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;
|
||||
|
@ -530,7 +530,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) {
|
||||
|
@ -549,8 +549,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;
|
||||
|
@ -590,13 +590,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;
|
||||
}
|
||||
|
@ -609,14 +609,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;
|
||||
|
@ -628,7 +628,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,
|
||||
|
@ -644,7 +644,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)
|
||||
|
@ -652,14 +652,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
|
||||
}
|
||||
|
@ -674,12 +674,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;
|
||||
|
@ -697,7 +697,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;
|
||||
|
@ -716,44 +716,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,
|
||||
|
@ -765,7 +765,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;
|
||||
|
@ -792,7 +792,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;
|
||||
|
@ -818,16 +818,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;
|
||||
|
@ -840,7 +840,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)
|
||||
|
@ -855,15 +855,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 {
|
||||
|
@ -876,8 +876,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);
|
||||
|
@ -900,7 +900,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);
|
||||
|
@ -922,7 +922,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);
|
||||
|
@ -947,7 +947,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);
|
||||
|
@ -960,7 +960,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);
|
||||
|
@ -990,14 +990,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;
|
||||
}
|
||||
|
@ -1053,7 +1053,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, PyInt_FromLong((long)(Py_Size(self))));
|
||||
PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_SIZE(self))));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1070,7 +1070,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,
|
||||
|
@ -1089,14 +1089,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];
|
||||
|
@ -1106,7 +1106,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];
|
||||
|
@ -1147,16 +1147,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(cs#)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);
|
||||
}
|
||||
|
@ -1175,9 +1175,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
|
||||
|
@ -1218,7 +1218,7 @@ array_fromfile(arrayobject *self, PyObject *args)
|
|||
Py_ssize_t newlength;
|
||||
size_t newbytes;
|
||||
/* Be careful here about overflow */
|
||||
if ((newlength = Py_Size(self) + n) <= 0 ||
|
||||
if ((newlength = Py_SIZE(self) + n) <= 0 ||
|
||||
(newbytes = newlength * itemsize) / itemsize !=
|
||||
(size_t)newlength)
|
||||
goto nomem;
|
||||
|
@ -1229,15 +1229,15 @@ array_fromfile(arrayobject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
nread = fread(item + (Py_Size(self) - n) * itemsize,
|
||||
Py_SIZE(self) += n;
|
||||
self->allocated = Py_SIZE(self);
|
||||
nread = fread(item + (Py_SIZE(self) - n) * itemsize,
|
||||
itemsize, n, fp);
|
||||
if (nread < (size_t)n) {
|
||||
Py_Size(self) -= (n - nread);
|
||||
PyMem_RESIZE(item, char, Py_Size(self)*itemsize);
|
||||
Py_SIZE(self) -= (n - nread);
|
||||
PyMem_RESIZE(item, char, Py_SIZE(self)*itemsize);
|
||||
self->ob_item = item;
|
||||
self->allocated = Py_Size(self);
|
||||
self->allocated = Py_SIZE(self);
|
||||
PyErr_SetString(PyExc_EOFError,
|
||||
"not enough items in file");
|
||||
return NULL;
|
||||
|
@ -1297,23 +1297,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;
|
||||
}
|
||||
}
|
||||
|
@ -1331,12 +1331,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);
|
||||
|
@ -1369,15 +1369,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);
|
||||
|
@ -1395,7 +1395,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,
|
||||
|
@ -1423,15 +1423,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));
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1456,7 @@ array_tounicode(arrayobject *self, PyObject *unused)
|
|||
"tounicode() may only be called on type 'u' 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,
|
||||
|
@ -1554,7 +1554,7 @@ array_repr(arrayobject *a)
|
|||
PyObject *s, *t, *v = NULL;
|
||||
Py_ssize_t len;
|
||||
|
||||
len = Py_Size(a);
|
||||
len = Py_SIZE(a);
|
||||
typecode = a->ob_descr->typecode;
|
||||
if (len == 0) {
|
||||
PyOS_snprintf(buf, sizeof(buf), "array('%c')", typecode);
|
||||
|
@ -1588,7 +1588,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)) {
|
||||
|
@ -1597,7 +1597,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;
|
||||
}
|
||||
|
@ -1651,8 +1651,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;
|
||||
|
@ -1669,7 +1669,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;
|
||||
}
|
||||
|
@ -1685,7 +1685,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;
|
||||
|
@ -1704,7 +1704,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;
|
||||
|
@ -1716,18 +1716,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,
|
||||
|
@ -1747,19 +1747,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;
|
||||
}
|
||||
|
@ -1802,7 +1802,7 @@ array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = (void *)self->ob_item;
|
||||
if (*ptr == NULL)
|
||||
*ptr = emptybuf;
|
||||
return Py_Size(self)*self->ob_descr->itemsize;
|
||||
return Py_SIZE(self)*self->ob_descr->itemsize;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
|
@ -1816,14 +1816,14 @@ array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = (void *)self->ob_item;
|
||||
if (*ptr == NULL)
|
||||
*ptr = emptybuf;
|
||||
return Py_Size(self)*self->ob_descr->itemsize;
|
||||
return Py_SIZE(self)*self->ob_descr->itemsize;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
array_buffer_getsegcount(arrayobject *self, Py_ssize_t *lenp)
|
||||
{
|
||||
if ( lenp )
|
||||
*lenp = Py_Size(self)*self->ob_descr->itemsize;
|
||||
*lenp = Py_SIZE(self)*self->ob_descr->itemsize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1932,9 +1932,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);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2103,7 +2103,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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -1412,7 +1412,7 @@ BZ2File_dealloc(BZ2FileObject *self)
|
|||
}
|
||||
Util_DropReadAhead(self);
|
||||
Py_XDECREF(self->file);
|
||||
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(). */
|
||||
|
@ -1728,7 +1728,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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1950,7 +1950,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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2200,9 +2200,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)
|
||||
|
|
|
@ -156,7 +156,7 @@ static PyTypeObject PdataType = {
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0L,0L,0L,0L, ""
|
||||
};
|
||||
|
||||
#define Pdata_Check(O) (Py_Type(O) == &PdataType)
|
||||
#define Pdata_Check(O) (Py_TYPE(O) == &PdataType)
|
||||
|
||||
static PyObject *
|
||||
Pdata_New(void)
|
||||
|
@ -316,7 +316,7 @@ Pdata_popList(Pdata *self, int start)
|
|||
}
|
||||
|
||||
#define FREE_ARG_TUP(self) { \
|
||||
if (Py_Refcnt(self->arg) > 1) { \
|
||||
if (Py_REFCNT(self->arg) > 1) { \
|
||||
Py_DECREF(self->arg); \
|
||||
self->arg=NULL; \
|
||||
} \
|
||||
|
@ -752,7 +752,7 @@ get(Picklerobject *self, PyObject *id)
|
|||
static int
|
||||
put(Picklerobject *self, PyObject *ob)
|
||||
{
|
||||
if (Py_Refcnt(ob) < 2 || self->fast)
|
||||
if (Py_REFCNT(ob) < 2 || self->fast)
|
||||
return 0;
|
||||
|
||||
return put2(self, ob);
|
||||
|
@ -916,7 +916,7 @@ fast_save_enter(Picklerobject *self, PyObject *obj)
|
|||
PyErr_Format(PyExc_ValueError,
|
||||
"fast mode: can't pickle cyclic objects "
|
||||
"including object type %s at %p",
|
||||
Py_Type(obj)->tp_name, obj);
|
||||
Py_TYPE(obj)->tp_name, obj);
|
||||
self->fast_container = -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2320,7 +2320,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
|||
goto finally;
|
||||
}
|
||||
|
||||
type = Py_Type(args);
|
||||
type = Py_TYPE(args);
|
||||
|
||||
switch (type->tp_name[0]) {
|
||||
case 'b':
|
||||
|
@ -2372,7 +2372,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (Py_Refcnt(args) > 1) {
|
||||
if (Py_REFCNT(args) > 1) {
|
||||
if (!( py_ob_id = PyLong_FromVoidPtr(args)))
|
||||
goto finally;
|
||||
|
||||
|
@ -2913,7 +2913,7 @@ Pickler_dealloc(Picklerobject *self)
|
|||
Py_XDECREF(self->inst_pers_func);
|
||||
Py_XDECREF(self->dispatch_table);
|
||||
PyMem_Free(self->write_buf);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -5253,7 +5253,7 @@ Unpickler_dealloc(Unpicklerobject *self)
|
|||
free(self->buf);
|
||||
}
|
||||
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -5706,9 +5706,9 @@ initcPickle(void)
|
|||
PyObject *format_version;
|
||||
PyObject *compatible_formats;
|
||||
|
||||
Py_Type(&Picklertype) = &PyType_Type;
|
||||
Py_Type(&Unpicklertype) = &PyType_Type;
|
||||
Py_Type(&PdataType) = &PyType_Type;
|
||||
Py_TYPE(&Picklertype) = &PyType_Type;
|
||||
Py_TYPE(&Unpicklertype) = &PyType_Type;
|
||||
Py_TYPE(&PdataType) = &PyType_Type;
|
||||
|
||||
/* Initialize some pieces. We need to do this before module creation,
|
||||
* so we're forced to use a temporary dictionary. :(
|
||||
|
|
|
@ -747,8 +747,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",
|
||||
|
|
|
@ -945,7 +945,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 = {
|
||||
|
@ -1145,7 +1145,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 = {
|
||||
|
@ -1461,7 +1461,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 = {
|
||||
|
@ -1663,7 +1663,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[] = {
|
||||
|
|
|
@ -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);
|
||||
|
@ -948,7 +948,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
|
|||
if (result != NULL && result != Py_None && ! PyString_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;
|
||||
}
|
||||
|
@ -1421,7 +1421,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;
|
||||
}
|
||||
|
||||
|
@ -1876,7 +1876,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;
|
||||
}
|
||||
|
||||
|
@ -1980,18 +1980,18 @@ delta_repr(PyDateTime_Delta *self)
|
|||
{
|
||||
if (GET_TD_MICROSECONDS(self) != 0)
|
||||
return PyString_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 PyString_FromFormat("%s(%d, %d)",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
GET_TD_DAYS(self),
|
||||
GET_TD_SECONDS(self));
|
||||
|
||||
return PyString_FromFormat("%s(%d)",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
GET_TD_DAYS(self));
|
||||
}
|
||||
|
||||
|
@ -2055,7 +2055,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)
|
||||
|
@ -2414,7 +2414,7 @@ date_repr(PyDateTime_Date *self)
|
|||
char buffer[1028];
|
||||
const char *type_name;
|
||||
|
||||
type_name = Py_Type(self)->tp_name;
|
||||
type_name = Py_TYPE(self)->tp_name;
|
||||
PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d)",
|
||||
type_name,
|
||||
GET_YEAR(self), GET_MONTH(self), GET_DAY(self));
|
||||
|
@ -2554,7 +2554,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;
|
||||
}
|
||||
|
@ -2604,7 +2604,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[] = {
|
||||
|
@ -2906,10 +2906,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[] = {
|
||||
|
@ -3104,7 +3104,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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3138,7 +3138,7 @@ static PyObject *
|
|||
time_repr(PyDateTime_Time *self)
|
||||
{
|
||||
char buffer[100];
|
||||
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);
|
||||
|
@ -3352,7 +3352,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;
|
||||
}
|
||||
|
@ -3406,7 +3406,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[] = {
|
||||
|
@ -3900,7 +3900,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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4049,7 +4049,7 @@ static PyObject *
|
|||
datetime_repr(PyDateTime_DateTime *self)
|
||||
{
|
||||
char buffer[1000];
|
||||
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)) {
|
||||
|
@ -4270,7 +4270,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;
|
||||
}
|
||||
|
@ -4458,7 +4458,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[] = {
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -62,7 +62,7 @@ dl_sym(dlobject *xp, PyObject *args)
|
|||
name = PyString_AS_STRING(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);
|
||||
|
@ -236,7 +236,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);
|
||||
|
|
|
@ -239,7 +239,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.
|
||||
|
@ -291,7 +291,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);
|
||||
|
@ -376,7 +376,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,
|
||||
|
@ -472,7 +472,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);
|
||||
|
@ -517,7 +517,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? */
|
||||
|
@ -654,7 +654,7 @@ debug_cycle(char *msg, PyObject *op)
|
|||
}
|
||||
else if (debug & DEBUG_OBJECTS) {
|
||||
PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
|
||||
msg, Py_Type(op)->tp_name, op);
|
||||
msg, Py_TYPE(op)->tp_name, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,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);
|
||||
|
@ -1079,7 +1079,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)) {
|
||||
|
@ -1136,7 +1136,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)) {
|
||||
|
@ -1359,13 +1359,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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)
|
||||
|
@ -2261,7 +2261,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
|
||||
|
@ -2284,12 +2284,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;
|
||||
|
@ -2305,7 +2305,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;
|
||||
|
@ -2411,7 +2411,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
|
||||
|
@ -2606,7 +2606,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
|
||||
|
@ -2632,7 +2632,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);
|
||||
|
@ -2641,7 +2641,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) {
|
||||
|
@ -2670,7 +2670,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) {
|
||||
|
@ -2801,7 +2801,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;
|
||||
|
|
|
@ -298,7 +298,7 @@ init_md5(void)
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
Py_Type(&MD5type) = &PyType_Type;
|
||||
Py_TYPE(&MD5type) = &PyType_Type;
|
||||
if (PyType_Ready(&MD5type) < 0)
|
||||
return;
|
||||
m = Py_InitModule3("_md5", md5_functions, module_doc);
|
||||
|
|
|
@ -1329,7 +1329,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)
|
||||
|
|
|
@ -693,7 +693,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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -706,7 +706,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);
|
||||
return 0;
|
||||
|
@ -3232,7 +3232,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;
|
||||
|
|
|
@ -2670,7 +2670,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 = PyInt_AsLong(intobj);
|
||||
|
|
|
@ -974,7 +974,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
|
|||
if (!PyString_Check(str)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"read() did not return a string object (type=%.400s)",
|
||||
Py_Type(str)->tp_name);
|
||||
Py_TYPE(str)->tp_name);
|
||||
goto finally;
|
||||
}
|
||||
len = PyString_GET_SIZE(str);
|
||||
|
@ -1859,7 +1859,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,
|
||||
|
|
|
@ -705,7 +705,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -576,7 +576,7 @@ init_sha(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
Py_Type(&SHAtype) = &PyType_Type;
|
||||
Py_TYPE(&SHAtype) = &PyType_Type;
|
||||
if (PyType_Ready(&SHAtype) < 0)
|
||||
return;
|
||||
m = Py_InitModule("_sha", SHA_functions);
|
||||
|
|
|
@ -1171,7 +1171,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))
|
||||
|
@ -1194,7 +1194,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",
|
||||
|
@ -1224,7 +1224,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",
|
||||
|
@ -1346,7 +1346,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|iis#", &interfaceName,
|
||||
|
@ -2769,7 +2769,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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3480,7 +3480,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));
|
||||
|
@ -3549,7 +3549,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));
|
||||
}
|
||||
|
||||
|
@ -4199,7 +4199,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);
|
||||
|
|
|
@ -42,8 +42,8 @@ static sadstatusobject *sads_alloc(void); /* Forward */
|
|||
|
||||
static PyObject *SunAudioError;
|
||||
|
||||
#define is_sadobject(v) (Py_Type(v) == &Sadtype)
|
||||
#define is_sadstatusobject(v) (Py_Type(v) == &Sadstatustype)
|
||||
#define is_sadobject(v) (Py_TYPE(v) == &Sadtype)
|
||||
#define is_sadstatusobject(v) (Py_TYPE(v) == &Sadstatustype)
|
||||
|
||||
|
||||
static sadobject *
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -181,7 +181,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 *
|
||||
|
|
|
@ -986,8 +986,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue