PEP 3123: Provide forward compatibility with Python 3.0, while keeping

backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
This commit is contained in:
Martin v. Löwis 2007-07-21 06:55:02 +00:00
parent b1994b4a5d
commit 6819210b9e
129 changed files with 1090 additions and 1250 deletions

View File

@ -1064,7 +1064,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
#define PySequence_ITEM(o, i)\
( o->ob_type->tp_as_sequence->sq_item(o, i) )
( Py_Type(o)->tp_as_sequence->sq_item(o, i) )
/* Assume tp_as_sequence and sq_item exist and that i does not
need to be corrected for a negative index
*/

View File

@ -11,7 +11,7 @@ typedef PyIntObject PyBoolObject;
PyAPI_DATA(PyTypeObject) PyBool_Type;
#define PyBool_Check(x) ((x)->ob_type == &PyBool_Type)
#define PyBool_Check(x) (Py_Type(x) == &PyBool_Type)
/* Py_False and Py_True are the only two bools in existence.
Don't forget to apply Py_INCREF() when returning either!!! */

View File

@ -12,7 +12,7 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
#define PyBuffer_Check(op) ((op)->ob_type == &PyBuffer_Type)
#define PyBuffer_Check(op) (Py_Type(op) == &PyBuffer_Type)
#define Py_END_OF_BUFFER (-1)

View File

@ -60,9 +60,9 @@ static struct PycStringIO_CAPI {
/* These can be used to test if you have one */
#define PycStringIO_InputCheck(O) \
((O)->ob_type==PycStringIO->InputType)
(Py_Type(O)==PycStringIO->InputType)
#define PycStringIO_OutputCheck(O) \
((O)->ob_type==PycStringIO->OutputType)
(Py_Type(O)==PycStringIO->OutputType)
#ifdef __cplusplus
}

View File

@ -13,7 +13,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyCell_Type;
#define PyCell_Check(op) ((op)->ob_type == &PyCell_Type)
#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type)
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);

View File

@ -16,7 +16,7 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PyCObject_Type;
#define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type)
#define PyCObject_Check(op) (Py_Type(op) == &PyCObject_Type)
/* Create a PyCObject from a pointer to a C object and an optional
destructor function. If the second argument is non-null, then it

View File

@ -60,7 +60,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyCode_Type;
#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
#define PyCode_Check(op) (Py_Type(op) == &PyCode_Type)
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
/* Public interface */
@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
/* for internal use only */
#define _PyCode_GETCODEPTR(co, pp) \
((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
((*Py_Type((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
((co)->co_code, 0, (void **)(pp)))
typedef struct _addr_pair {

View File

@ -43,7 +43,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyComplex_Type;
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
#define PyComplex_CheckExact(op) ((op)->ob_type == &PyComplex_Type)
#define PyComplex_CheckExact(op) (Py_Type(op) == &PyComplex_Type)
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);

View File

@ -166,19 +166,19 @@ typedef struct {
/* Macros for type checking when building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
#define PyDate_CheckExact(op) ((op)->ob_type == &PyDateTime_DateType)
#define PyDate_CheckExact(op) (Py_Type(op) == &PyDateTime_DateType)
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
#define PyDateTime_CheckExact(op) ((op)->ob_type == &PyDateTime_DateTimeType)
#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType)
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
#define PyTime_CheckExact(op) ((op)->ob_type == &PyDateTime_TimeType)
#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType)
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
#define PyDelta_CheckExact(op) ((op)->ob_type == &PyDateTime_DeltaType)
#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType)
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
#define PyTZInfo_CheckExact(op) ((op)->ob_type == &PyDateTime_TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_Type(op) == &PyDateTime_TZInfoType)
#else
@ -198,19 +198,19 @@ static PyDateTime_CAPI *PyDateTimeAPI;
/* Macros for type checking when not building the Python core. */
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
#define PyDate_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DateType)
#define PyDate_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateType)
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
#define PyDateTime_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DateTimeType)
#define PyDateTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateTimeType)
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
#define PyTime_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->TimeType)
#define PyTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TimeType)
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
#define PyDelta_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DeltaType)
#define PyDelta_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DeltaType)
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
#define PyTZInfo_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->TZInfoType)
#define PyTZInfo_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TZInfoType)
/* Macros for accessing constructors in a simplified fashion. */
#define PyDate_FromDate(year, month, day) \

View File

@ -77,7 +77,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
struct PyGetSetDef *);
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
struct wrapperbase *, void *);
#define PyDescr_IsData(d) ((d)->ob_type->tp_descr_set != NULL)
#define PyDescr_IsData(d) (Py_Type(d)->tp_descr_set != NULL)
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);

View File

@ -91,8 +91,8 @@ struct _dictobject {
PyAPI_DATA(PyTypeObject) PyDict_Type;
#define PyDict_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_DICT_SUBCLASS)
#define PyDict_CheckExact(op) ((op)->ob_type == &PyDict_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_DICT_SUBCLASS)
#define PyDict_CheckExact(op) (Py_Type(op) == &PyDict_Type)
PyAPI_FUNC(PyObject *) PyDict_New(void);
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);

View File

@ -30,7 +30,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyFile_Type;
#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type)
#define PyFile_CheckExact(op) ((op)->ob_type == &PyFile_Type)
#define PyFile_CheckExact(op) (Py_Type(op) == &PyFile_Type)
PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *);
PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int);

View File

@ -19,7 +19,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyFloat_Type;
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
#define PyFloat_CheckExact(op) ((op)->ob_type == &PyFloat_Type)
#define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type)
/* Return Python float from string PyObject. Second argument ignored on
input, and, if non-NULL, NULL is stored into *junk (this tried to serve a

View File

@ -39,7 +39,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyFunction_Type;
#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
#define PyFunction_Check(op) (Py_Type(op) == &PyFunction_Type)
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);

View File

@ -26,7 +26,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyGen_Type;
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
#define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type)
#define PyGen_CheckExact(op) (Py_Type(op) == &PyGen_Type)
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);

View File

@ -7,13 +7,13 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
#define PySeqIter_Check(op) ((op)->ob_type == &PySeqIter_Type)
#define PySeqIter_Check(op) (Py_Type(op) == &PySeqIter_Type)
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
#define PyCallIter_Check(op) ((op)->ob_type == &PyCallIter_Type)
#define PyCallIter_Check(op) (Py_Type(op) == &PyCallIter_Type)
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
#ifdef __cplusplus

View File

@ -41,8 +41,8 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyList_Type;
#define PyList_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_LIST_SUBCLASS)
#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LIST_SUBCLASS)
#define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type)
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
@ -60,7 +60,7 @@ PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
/* Macro, trading safety for speed */
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
#define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
#define PyList_GET_SIZE(op) Py_Size(op)
#ifdef __cplusplus
}

View File

@ -12,8 +12,8 @@ typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
PyAPI_DATA(PyTypeObject) PyLong_Type;
#define PyLong_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_LONG_SUBCLASS)
#define PyLong_CheckExact(op) ((op)->ob_type == &PyLong_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LONG_SUBCLASS)
#define PyLong_CheckExact(op) (Py_Type(op) == &PyLong_Type)
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);

View File

@ -13,7 +13,7 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
#define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type)
#define PyCFunction_Check(op) (Py_Type(op) == &PyCFunction_Type)
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,

View File

@ -10,7 +10,7 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PyModule_Type;
#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
#define PyModule_CheckExact(op) ((op)->ob_type == &PyModule_Type)
#define PyModule_CheckExact(op) (Py_Type(op) == &PyModule_Type)
PyAPI_FUNC(PyObject *) PyModule_New(const char *);
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);

View File

@ -84,6 +84,9 @@ whose size is determined when the object is allocated.
_PyObject_EXTRA_INIT \
1, type,
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
/* PyObject_VAR_HEAD defines the initial segment of all variable-size
* container objects. These end with a declaration of an array with 1
* element, but enough space is malloc'ed so that the array actually
@ -108,6 +111,9 @@ typedef struct {
PyObject_VAR_HEAD
} PyVarObject;
#define Py_Refcnt(ob) (((PyObject*)(ob))->ob_refcnt)
#define Py_Type(ob) (((PyObject*)(ob))->ob_type)
#define Py_Size(ob) (((PyVarObject*)(ob))->ob_size)
/*
Type objects contain a string containing the type name (to help somewhat
@ -364,21 +370,21 @@ typedef struct _heaptypeobject {
/* access macro to the members which are floating "behind" the object */
#define PyHeapType_GET_MEMBERS(etype) \
((PyMemberDef *)(((char *)etype) + (etype)->ht_type.ob_type->tp_basicsize))
((PyMemberDef *)(((char *)etype) + Py_Type(etype)->tp_basicsize))
/* Generic type check */
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
#define PyObject_TypeCheck(ob, tp) \
((ob)->ob_type == (tp) || PyType_IsSubtype((ob)->ob_type, (tp)))
(Py_Type(ob) == (tp) || PyType_IsSubtype(Py_Type(ob), (tp)))
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
#define PyType_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_TYPE_SUBCLASS)
#define PyType_CheckExact(op) ((op)->ob_type == &PyType_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TYPE_SUBCLASS)
#define PyType_CheckExact(op) (Py_Type(op) == &PyType_Type)
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
@ -599,7 +605,7 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
#define _Py_DEC_REFTOTAL _Py_RefTotal--
#define _Py_REF_DEBUG_COMMA ,
#define _Py_CHECK_REFCNT(OP) \
{ if ((OP)->ob_refcnt < 0) \
{ if (((PyObject*)OP)->ob_refcnt < 0) \
_Py_NegativeRefcount(__FILE__, __LINE__, \
(PyObject *)(OP)); \
}
@ -613,9 +619,9 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
#ifdef COUNT_ALLOCS
PyAPI_FUNC(void) inc_count(PyTypeObject *);
PyAPI_FUNC(void) dec_count(PyTypeObject *);
#define _Py_INC_TPALLOCS(OP) inc_count((OP)->ob_type)
#define _Py_INC_TPFREES(OP) dec_count((OP)->ob_type)
#define _Py_DEC_TPFREES(OP) (OP)->ob_type->tp_frees--
#define _Py_INC_TPALLOCS(OP) inc_count(Py_Type(OP))
#define _Py_INC_TPFREES(OP) dec_count(Py_Type(OP))
#define _Py_DEC_TPFREES(OP) Py_Type(OP)->tp_frees--
#define _Py_COUNT_ALLOCS_COMMA ,
#else
#define _Py_INC_TPALLOCS(OP)
@ -640,22 +646,22 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
#define _Py_NewReference(op) ( \
_Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
(op)->ob_refcnt = 1)
Py_Refcnt(op) = 1)
#define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
#define _Py_Dealloc(op) ( \
_Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \
(*(op)->ob_type->tp_dealloc)((PyObject *)(op)))
(*Py_Type(op)->tp_dealloc)((PyObject *)(op)))
#endif /* !Py_TRACE_REFS */
#define Py_INCREF(op) ( \
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
(op)->ob_refcnt++)
((PyObject*)(op))->ob_refcnt++)
#define Py_DECREF(op) \
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
--(op)->ob_refcnt != 0) \
--((PyObject*)(op))->ob_refcnt != 0) \
_Py_CHECK_REFCNT(op) \
else \
_Py_Dealloc((PyObject *)(op))

View File

@ -154,9 +154,9 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
/* Macros trading binary compatibility for speed. See also pymem.h.
Note that these macros expect non-NULL object pointers.*/
#define PyObject_INIT(op, typeobj) \
( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
( Py_Type(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
#define PyObject_INIT_VAR(op, typeobj, size) \
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
( Py_Size(op) = (size), PyObject_INIT((op), (typeobj)) )
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
@ -231,8 +231,8 @@ PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
/* Test if an object has a GC head */
#define PyObject_IS_GC(o) (PyType_IS_GC((o)->ob_type) && \
((o)->ob_type->tp_is_gc == NULL || (o)->ob_type->tp_is_gc(o)))
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_Type(o)) && \
(Py_Type(o)->tp_is_gc == NULL || Py_Type(o)->tp_is_gc(o)))
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
#define PyObject_GC_Resize(type, op, n) \
@ -328,7 +328,7 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
&& ((t)->tp_weaklistoffset > 0))
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset))
((PyObject **) (((char *) (o)) + Py_Type(o)->tp_weaklistoffset))
#ifdef __cplusplus
}

View File

@ -73,7 +73,7 @@ typedef struct {
WINDOW *win;
} PyCursesWindowObject;
#define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
#define PyCursesWindow_Check(v) (Py_Type(v) == &PyCursesWindow_Type)
#ifdef CURSES_MODULE
/* This section is used when compiling _cursesmodule.c */

View File

@ -20,7 +20,7 @@ they are represented by a start, stop, and step datamembers.
PyAPI_DATA(PyTypeObject) PyRange_Type;
#define PyRange_Check(op) ((op)->ob_type == &PyRange_Type)
#define PyRange_Check(op) (Py_Type(op) == &PyRange_Type)
#ifdef __cplusplus
}

View File

@ -66,13 +66,13 @@ PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
* hash is -1
*/
#define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type)
#define PyFrozenSet_CheckExact(ob) (Py_Type(ob) == &PyFrozenSet_Type)
#define PyAnySet_CheckExact(ob) \
((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type)
(Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type)
#define PyAnySet_Check(ob) \
((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type || \
PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \
PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type))
(Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type || \
PyType_IsSubtype(Py_Type(ob), &PySet_Type) || \
PyType_IsSubtype(Py_Type(ob), &PyFrozenSet_Type))
PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);

View File

@ -26,7 +26,7 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PySlice_Type;
#define PySlice_Check(op) ((op)->ob_type == &PySlice_Type)
#define PySlice_Check(op) (Py_Type(op) == &PySlice_Type)
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
PyObject* step);

View File

@ -56,8 +56,8 @@ PyAPI_DATA(PyTypeObject) PyBaseString_Type;
PyAPI_DATA(PyTypeObject) PyString_Type;
#define PyString_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_STRING_SUBCLASS)
#define PyString_CheckExact(op) ((op)->ob_type == &PyString_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_STRING_SUBCLASS)
#define PyString_CheckExact(op) (Py_Type(op) == &PyString_Type)
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
@ -89,7 +89,7 @@ PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void);
/* Macro, trading safety for speed */
#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
#define PyString_GET_SIZE(op) (((PyStringObject *)(op))->ob_size)
#define PyString_GET_SIZE(op) Py_Size(op)
/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*,
x must be an iterable object. */

View File

@ -49,7 +49,7 @@ typedef struct _symtable_entry {
PyAPI_DATA(PyTypeObject) PySTEntry_Type;
#define PySTEntry_Check(op) ((op)->ob_type == &PySTEntry_Type)
#define PySTEntry_Check(op) (Py_Type(op) == &PySTEntry_Type)
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);

View File

@ -22,7 +22,7 @@ PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
/* Reveal traceback type so we can typecheck traceback objects */
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
#define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type)
#define PyTraceBack_Check(v) (Py_Type(v) == &PyTraceBack_Type)
#ifdef __cplusplus
}

View File

@ -34,8 +34,8 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyTuple_Type;
#define PyTuple_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_TUPLE_SUBCLASS)
#define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TUPLE_SUBCLASS)
#define PyTuple_CheckExact(op) (Py_Type(op) == &PyTuple_Type)
PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
@ -47,7 +47,7 @@ PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
/* Macro, trading safety for speed */
#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
#define PyTuple_GET_SIZE(op) (((PyTupleObject *)(op))->ob_size)
#define PyTuple_GET_SIZE(op) Py_Size(op)
/* Macro, *only* to be used to fill in brand new tuples */
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)

View File

@ -393,8 +393,8 @@ typedef struct {
PyAPI_DATA(PyTypeObject) PyUnicode_Type;
#define PyUnicode_Check(op) \
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_UNICODE_SUBCLASS)
#define PyUnicode_CheckExact(op) ((op)->ob_type == &PyUnicode_Type)
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_UNICODE_SUBCLASS)
#define PyUnicode_CheckExact(op) (Py_Type(op) == &PyUnicode_Type)
/* Fast access macros */
#define PyUnicode_GET_SIZE(op) \

View File

@ -44,10 +44,10 @@ PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
#define PyWeakref_CheckRefExact(op) \
((op)->ob_type == &_PyWeakref_RefType)
(Py_Type(op) == &_PyWeakref_RefType)
#define PyWeakref_CheckProxy(op) \
(((op)->ob_type == &_PyWeakref_ProxyType) || \
((op)->ob_type == &_PyWeakref_CallableProxyType))
((Py_Type(op) == &_PyWeakref_ProxyType) || \
(Py_Type(op) == &_PyWeakref_CallableProxyType))
/* This macro calls PyWeakref_CheckRef() last since that can involve a
function call; this makes it more likely that the function call

View File

@ -12,6 +12,10 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
- Patch #1673759: add a missing overflow check when formatting floats
with %G.

View File

@ -300,13 +300,13 @@ staticforward PyTypeObject DBSequence_Type;
staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type;
#define DBObject_Check(v) ((v)->ob_type == &DB_Type)
#define DBCursorObject_Check(v) ((v)->ob_type == &DBCursor_Type)
#define DBEnvObject_Check(v) ((v)->ob_type == &DBEnv_Type)
#define DBTxnObject_Check(v) ((v)->ob_type == &DBTxn_Type)
#define DBLockObject_Check(v) ((v)->ob_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)
#if (DBVER >= 43)
#define DBSequenceObject_Check(v) ((v)->ob_type == &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,
"String or Integer object expected for key, %s found",
keyobj->ob_type->tp_name);
Py_Type(keyobj)->tp_name);
return 0;
}
@ -616,7 +616,7 @@ static int makeDBError(int err)
static void makeTypeError(char* expected, PyObject* found)
{
PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.",
expected, found->ob_type->tp_name);
expected, Py_Type(found)->tp_name);
}
@ -5666,13 +5666,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++. */
DB_Type.ob_type = &PyType_Type;
DBCursor_Type.ob_type = &PyType_Type;
DBEnv_Type.ob_type = &PyType_Type;
DBTxn_Type.ob_type = &PyType_Type;
DBLock_Type.ob_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)
DBSequence_Type.ob_type = &PyType_Type;
Py_Type(&DBSequence_Type) = &PyType_Type;
#endif

View File

@ -544,7 +544,7 @@ deque_dealloc(dequeobject *deque)
}
deque->leftblock = NULL;
deque->rightblock = NULL;
deque->ob_type->tp_free(deque);
Py_Type(deque)->tp_free(deque);
}
static int
@ -579,7 +579,7 @@ deque_nohash(PyObject *self)
static PyObject *
deque_copy(PyObject *deque)
{
return PyObject_CallFunctionObjArgs((PyObject *)(deque->ob_type),
return PyObject_CallFunctionObjArgs((PyObject *)(Py_Type(deque)),
deque, NULL);
}
@ -601,7 +601,7 @@ deque_reduce(dequeobject *deque)
Py_DECREF(dict);
return NULL;
}
result = Py_BuildValue("O()ON", deque->ob_type, dict, it);
result = Py_BuildValue("O()ON", Py_Type(deque), dict, it);
Py_DECREF(dict);
return result;
}
@ -825,8 +825,7 @@ PyDoc_STRVAR(deque_doc,
Build an ordered collection accessible from endpoints only.");
static PyTypeObject deque_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"collections.deque", /* tp_name */
sizeof(dequeobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -903,7 +902,7 @@ static void
dequeiter_dealloc(dequeiterobject *dio)
{
Py_XDECREF(dio->deque);
dio->ob_type->tp_free(dio);
Py_Type(dio)->tp_free(dio);
}
static PyObject *
@ -948,8 +947,7 @@ static PyMethodDef dequeiter_methods[] = {
};
PyTypeObject dequeiter_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"deque_iterator", /* tp_name */
sizeof(dequeiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1031,8 +1029,7 @@ dequereviter_next(dequeiterobject *it)
}
PyTypeObject dequereviter_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"deque_reverse_iterator", /* tp_name */
sizeof(dequeiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1113,7 +1110,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 *)dd->dict.ob_type,
return PyObject_CallFunctionObjArgs(Py_Type(dd),
dd->default_factory, dd, NULL);
}
@ -1156,7 +1153,7 @@ defdict_reduce(defdictobject *dd)
Py_DECREF(args);
return NULL;
}
result = PyTuple_Pack(5, dd->dict.ob_type, args,
result = PyTuple_Pack(5, Py_Type(dd), args,
Py_None, Py_None, items);
Py_DECREF(items);
Py_DECREF(args);
@ -1288,8 +1285,7 @@ A defaultdict compares equal to a dict with the same items.\n\
#define DEFERRED_ADDRESS(ADDR) 0
static PyTypeObject defdict_type = {
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
0, /* ob_size */
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
"collections.defaultdict", /* tp_name */
sizeof(defdictobject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -125,7 +125,7 @@ typedef struct {
staticforward PyTypeObject Reader_Type;
#define ReaderObject_Check(v) ((v)->ob_type == &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);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
static char *dialect_kws[] = {
@ -460,8 +460,7 @@ PyDoc_STRVAR(Dialect_Type_doc,
"The Dialect type records CSV parsing and generation options.\n");
static PyTypeObject Dialect_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_csv.Dialect", /* tp_name */
sizeof(DialectObj), /* tp_basicsize */
0, /* tp_itemsize */
@ -869,8 +868,7 @@ static struct PyMemberDef Reader_memberlist[] = {
static PyTypeObject Reader_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_csv.reader", /*tp_name*/
sizeof(ReaderObj), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -1280,8 +1278,7 @@ PyDoc_STRVAR(Writer_Type_doc,
);
static PyTypeObject Writer_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_csv.writer", /*tp_name*/
sizeof(WriterObj), /*tp_basicsize*/
0, /*tp_itemsize*/

View File

@ -333,7 +333,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
Py_INCREF(value);
return value;
}
ob_name = (ob) ? ob->ob_type->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,
value->ob_type->tp_name);
Py_Type(value)->tp_name);
return NULL;
}
@ -435,8 +435,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value)
PyTypeObject StructType_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.StructType", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
@ -478,8 +477,7 @@ PyTypeObject StructType_Type = {
};
static PyTypeObject UnionType_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.UnionType", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
@ -693,8 +691,7 @@ static PyMethodDef PointerType_methods[] = {
};
PyTypeObject PointerType_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.PointerType", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
@ -751,7 +748,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
char *ptr;
Py_ssize_t size;
if (PyBuffer_Check(value)) {
size = value->ob_type->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)) {
@ -800,7 +797,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
} else if (!PyString_Check(value)) {
PyErr_Format(PyExc_TypeError,
"string expected instead of %s instance",
value->ob_type->tp_name);
Py_Type(value)->tp_name);
return -1;
} else
Py_INCREF(value);
@ -855,7 +852,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
} else if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError,
"unicode string expected instead of %s instance",
value->ob_type->tp_name);
Py_Type(value)->tp_name);
return -1;
} else
Py_INCREF(value);
@ -1051,8 +1048,7 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyTypeObject ArrayType_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.ArrayType", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
@ -1684,8 +1680,7 @@ static PyMethodDef SimpleType_methods[] = {
};
PyTypeObject SimpleType_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.SimpleType", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
@ -1899,8 +1894,7 @@ CFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyTypeObject CFuncPtrType_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.CFuncPtrType", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
@ -2076,7 +2070,7 @@ static void
CData_dealloc(PyObject *self)
{
CData_clear((CDataObject *)self);
self->ob_type->tp_free(self);
Py_Type(self)->tp_free(self);
}
static PyMemberDef CData_members[] = {
@ -2143,8 +2137,7 @@ static PyMethodDef CData_methods[] = {
};
PyTypeObject CData_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._CData",
sizeof(CDataObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2350,7 +2343,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
PyErr_Format(PyExc_TypeError,
"expected %s instance, got %s",
((PyTypeObject *)type)->tp_name,
value->ob_type->tp_name);
Py_Type(value)->tp_name);
return NULL;
}
}
@ -2381,7 +2374,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",
value->ob_type->tp_name,
Py_Type(value)->tp_name,
((PyTypeObject *)type)->tp_name);
return NULL;
}
@ -2400,7 +2393,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
}
PyErr_Format(PyExc_TypeError,
"incompatible types, %s instance instead of %s instance",
value->ob_type->tp_name,
Py_Type(value)->tp_name,
((PyTypeObject *)type)->tp_name);
return NULL;
}
@ -2661,7 +2654,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 :
arg->ob_type->tp_name);
Py_Type(arg)->tp_name);
return 0;
}
@ -3447,7 +3440,7 @@ static void
CFuncPtr_dealloc(CFuncPtrObject *self)
{
CFuncPtr_clear(self);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
static PyObject *
@ -3457,17 +3450,16 @@ CFuncPtr_repr(CFuncPtrObject *self)
if (self->index)
return PyString_FromFormat("<COM method offset %d: %s at %p>",
self->index - 0x1000,
self->ob_type->tp_name,
Py_Type(self)->tp_name,
self);
#endif
return PyString_FromFormat("<%s object at %p>",
self->ob_type->tp_name,
Py_Type(self)->tp_name,
self);
}
PyTypeObject CFuncPtr_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.CFuncPtr",
sizeof(CFuncPtrObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -3595,8 +3587,7 @@ Struct_init(PyObject *self, PyObject *args, PyObject *kwds)
}
static PyTypeObject Struct_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.Structure",
sizeof(CDataObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -3638,8 +3629,7 @@ static PyTypeObject Struct_Type = {
};
static PyTypeObject Union_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.Union",
sizeof(CDataObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -3871,8 +3861,7 @@ static PySequenceMethods Array_as_sequence = {
};
PyTypeObject Array_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.Array",
sizeof(CDataObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -4025,7 +4014,7 @@ static PyGetSetDef Simple_getsets[] = {
static PyObject *
Simple_from_outparm(PyObject *self, PyObject *args)
{
if (IsSimpleSubType((PyObject *)self->ob_type)) {
if (IsSimpleSubType((PyObject *)Py_Type(self))) {
Py_INCREF(self);
return self;
}
@ -4090,9 +4079,9 @@ Simple_repr(CDataObject *self)
PyObject *val, *name, *args, *result;
static PyObject *format;
if (self->ob_type->tp_base != &Simple_Type) {
if (Py_Type(self)->tp_base != &Simple_Type) {
return PyString_FromFormat("<%s object at %p>",
self->ob_type->tp_name, self);
Py_Type(self)->tp_name, self);
}
if (format == NULL) {
@ -4105,7 +4094,7 @@ Simple_repr(CDataObject *self)
if (val == NULL)
return NULL;
name = PyString_FromString(self->ob_type->tp_name);
name = PyString_FromString(Py_Type(self)->tp_name);
if (name == NULL) {
Py_DECREF(val);
return NULL;
@ -4123,8 +4112,7 @@ Simple_repr(CDataObject *self)
}
static PyTypeObject Simple_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._SimpleCData",
sizeof(CDataObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -4277,7 +4265,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure)
PyErr_Format(PyExc_TypeError,
"expected %s instead of %s",
((PyTypeObject *)(stgdict->proto))->tp_name,
value->ob_type->tp_name);
Py_Type(value)->tp_name);
return -1;
}
@ -4406,8 +4394,7 @@ static PyNumberMethods Pointer_as_number = {
};
PyTypeObject Pointer_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._Pointer",
sizeof(CDataObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -4585,7 +4572,7 @@ cast_check_pointertype(PyObject *arg)
"cast() argument 2 must be a pointer type, not %s",
PyType_Check(arg)
? ((PyTypeObject *)arg)->tp_name
: arg->ob_type->tp_name);
: Py_Type(arg)->tp_name);
return 0;
}
@ -4712,37 +4699,37 @@ init_ctypes(void)
if (PyType_Ready(&CData_Type) < 0)
return;
Struct_Type.ob_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);
Union_Type.ob_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);
Pointer_Type.ob_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);
Array_Type.ob_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);
Simple_Type.ob_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);
CFuncPtr_Type.ob_type = &CFuncPtrType_Type;
Py_Type(&CFuncPtr_Type) = &CFuncPtrType_Type;
CFuncPtr_Type.tp_base = &CData_Type;
if (PyType_Ready(&CFuncPtr_Type) < 0)
return;

View File

@ -381,8 +381,7 @@ static PyMemberDef PyCArgType_members[] = {
};
PyTypeObject PyCArg_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"CArgObject",
sizeof(PyCArgObject),
0,
@ -1180,7 +1179,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",
pcom->ob_type->tp_name);
Py_Type(pcom)->tp_name);
return NULL;
}
@ -1420,7 +1419,7 @@ byref(PyObject *self, PyObject *obj)
if (!CDataObject_Check(obj)) {
PyErr_Format(PyExc_TypeError,
"byref() argument must be a ctypes instance, not '%s'",
obj->ob_type->tp_name);
Py_Type(obj)->tp_name);
return NULL;
}

View File

@ -286,8 +286,7 @@ CField_repr(CFieldObject *self)
}
PyTypeObject CField_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.CField", /* tp_name */
sizeof(CFieldObject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -83,8 +83,7 @@ StgDict_clone(StgDictObject *dst, StgDictObject *src)
}
PyTypeObject StgDict_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"StgDict",
sizeof(StgDictObject),
0,
@ -192,7 +191,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
Py_DECREF(fieldlist);
return -1;
}
if (fdescr->ob_type != &CField_Type) {
if (Py_Type(fdescr) != &CField_Type) {
PyErr_SetString(PyExc_TypeError, "unexpected type");
Py_DECREF(fdescr);
Py_DECREF(fieldlist);
@ -215,7 +214,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
Py_DECREF(fieldlist);
return -1;
}
assert(new_descr->ob_type == &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;
@ -263,7 +262,7 @@ MakeAnonFields(PyObject *type)
Py_DECREF(anon_names);
return -1;
}
assert(descr->ob_type == &CField_Type);
assert(Py_Type(descr) == &CField_Type);
descr->anonymous = 1;
/* descr is in the field descriptor. */

View File

@ -56,7 +56,7 @@ typedef struct {
PyTypeObject PyCursesPanel_Type;
#define PyCursesPanel_Check(v) ((v)->ob_type == &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
@ -338,8 +338,7 @@ PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name)
/* -------------------------------------------------------*/
PyTypeObject PyCursesPanel_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_curses_panel.curses panel", /*tp_name*/
sizeof(PyCursesPanelObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -458,7 +457,7 @@ init_curses_panel(void)
PyObject *m, *d, *v;
/* Initialize object type */
PyCursesPanel_Type.ob_type = &PyType_Type;
Py_Type(&PyCursesPanel_Type) = &PyType_Type;
import_curses();

View File

@ -1566,8 +1566,7 @@ PyCursesWindow_GetAttr(PyCursesWindowObject *self, char *name)
/* -------------------------------------------------------*/
PyTypeObject PyCursesWindow_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_curses.curses window", /*tp_name*/
sizeof(PyCursesWindowObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -2657,7 +2656,7 @@ init_curses(void)
static void *PyCurses_API[PyCurses_API_pointers];
/* Initialize object type */
PyCursesWindow_Type.ob_type = &PyType_Type;
Py_Type(&PyCursesWindow_Type) = &PyType_Type;
/* Initialize the C API pointer array */
PyCurses_API[0] = (void *)&PyCursesWindow_Type;

View File

@ -269,7 +269,7 @@ typedef struct {
staticforward PyTypeObject Element_Type;
#define Element_CheckExact(op) ((op)->ob_type == &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\"", item->ob_type->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) ((op)->ob_type == &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) && self->data->ob_refcnt == 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 */
Element_Type.ob_type = TreeBuilder_Type.ob_type = &PyType_Type;
Py_Type(&Element_Type) = Py_Type(&TreeBuilder_Type) = &PyType_Type;
#if defined(USE_EXPAT)
XMLParser_Type.ob_type = &PyType_Type;
Py_Type(&XMLParser_Type) = &PyType_Type;
#endif
m = Py_InitModule("_elementtree", _functions);

View File

@ -81,7 +81,7 @@ partial_dealloc(partialobject *pto)
Py_XDECREF(pto->args);
Py_XDECREF(pto->kw);
Py_XDECREF(pto->dict);
pto->ob_type->tp_free(pto);
Py_Type(pto)->tp_free(pto);
}
static PyObject *
@ -197,8 +197,7 @@ static PyGetSetDef partial_getsetlist[] = {
};
static PyTypeObject partial_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"functools.partial", /* tp_name */
sizeof(partialobject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -281,8 +281,7 @@ name -- the hash algorithm being used by this object\n\
digest_size -- number of bytes in this hashes output\n");
static PyTypeObject EVPtype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_hashlib.HASH", /*tp_name*/
sizeof(EVPobject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -464,7 +463,7 @@ init_hashlib(void)
* but having some be unsupported. Only init appropriate
* constants. */
EVPtype.ob_type = &PyType_Type;
Py_Type(&EVPtype) = &PyType_Type;
if (PyType_Ready(&EVPtype) < 0)
return;

View File

@ -1220,8 +1220,7 @@ PyDoc_STRVAR(profiler_object__doc__,
"linetimings: True if line events collect timing information.");
static PyTypeObject ProfilerType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_hotshot.ProfilerType", /* tp_name */
(int) sizeof(ProfilerObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1305,8 +1304,7 @@ static PyGetSetDef logreader_getsets[] = {
};
static PyTypeObject LogReaderType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_hotshot.LogReaderType", /* tp_name */
(int) sizeof(LogReaderObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1613,8 +1611,8 @@ init_hotshot(void)
{
PyObject *module;
LogReaderType.ob_type = &PyType_Type;
ProfilerType.ob_type = &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();

View File

@ -120,7 +120,7 @@ typedef struct {
staticforward PyTypeObject PyProfiler_Type;
#define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type)
#define PyProfiler_CheckExact(op) ((op)->ob_type == &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(self->ob_type, name);
PyObject *mo = _PyType_Lookup(Py_Type(self), name);
Py_XINCREF(mo);
Py_DECREF(name);
if (mo != NULL) {
@ -744,7 +744,7 @@ profiler_dealloc(ProfilerObject *op)
flush_unmatched(op);
clearEntries(op);
Py_XDECREF(op->externalTimer);
op->ob_type->tp_free(op);
Py_Type(op)->tp_free(op);
}
static int

View File

@ -84,7 +84,7 @@ typedef struct {
static PyTypeObject Random_Type;
#define RandomObject_Check(v) ((v)->ob_type == &Random_Type)
#define RandomObject_Check(v) (Py_Type(v) == &Random_Type)
/* Random methods */
@ -404,7 +404,7 @@ random_jumpahead(RandomObject *self, PyObject *n)
if (!PyInt_Check(n) && !PyLong_Check(n)) {
PyErr_Format(PyExc_TypeError, "jumpahead requires an "
"integer, not '%s'",
n->ob_type->tp_name);
Py_Type(n)->tp_name);
return NULL;
}
@ -518,8 +518,7 @@ PyDoc_STRVAR(random_doc,
"Random() -> create a random number generator with its own internal state.");
static PyTypeObject Random_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_random.Random", /*tp_name*/
sizeof(RandomObject), /*tp_basicsize*/
0, /*tp_itemsize*/

View File

@ -51,7 +51,7 @@ void pysqlite_node_dealloc(pysqlite_Node* self)
Py_DECREF(self->key);
Py_DECREF(self->data);
self->ob_type->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);
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
@ -274,8 +274,7 @@ static PyMethodDef cache_methods[] = {
};
PyTypeObject pysqlite_NodeType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME "Node", /* tp_name */
sizeof(pysqlite_Node), /* tp_basicsize */
0, /* tp_itemsize */
@ -317,8 +316,7 @@ PyTypeObject pysqlite_NodeType = {
};
PyTypeObject pysqlite_CacheType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME ".Cache", /* tp_name */
sizeof(pysqlite_Cache), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -205,7 +205,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
Py_XDECREF(self->collations);
Py_XDECREF(self->statements);
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
@ -1206,8 +1206,7 @@ static struct PyMemberDef connection_members[] =
};
PyTypeObject pysqlite_ConnectionType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME ".Connection", /* tp_name */
sizeof(pysqlite_Connection), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -134,7 +134,7 @@ void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
Py_XDECREF(self->row_factory);
Py_XDECREF(self->next_row);
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
PyObject* _pysqlite_get_converter(PyObject* key)
@ -1020,8 +1020,7 @@ static char cursor_doc[] =
PyDoc_STR("SQLite database cursor class.");
PyTypeObject pysqlite_CursorType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME ".Cursor", /* tp_name */
sizeof(pysqlite_Cursor), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -30,12 +30,11 @@ int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* arg
void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self)
{
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
PyTypeObject pysqlite_PrepareProtocolType= {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME ".PrepareProtocol", /* tp_name */
sizeof(pysqlite_PrepareProtocol), /* tp_basicsize */
0, /* tp_itemsize */
@ -79,6 +78,6 @@ PyTypeObject pysqlite_PrepareProtocolType= {
extern int pysqlite_prepare_protocol_setup_types(void)
{
pysqlite_PrepareProtocolType.tp_new = PyType_GenericNew;
pysqlite_PrepareProtocolType.ob_type= &PyType_Type;
Py_Type(&pysqlite_PrepareProtocolType)= &PyType_Type;
return PyType_Ready(&pysqlite_PrepareProtocolType);
}

View File

@ -30,7 +30,7 @@ void pysqlite_row_dealloc(pysqlite_Row* self)
Py_XDECREF(self->data);
Py_XDECREF(self->description);
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs)
@ -183,8 +183,7 @@ static PyMethodDef pysqlite_row_methods[] = {
PyTypeObject pysqlite_RowType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME ".Row", /* tp_name */
sizeof(pysqlite_Row), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -309,7 +309,7 @@ void pysqlite_statement_dealloc(pysqlite_Statement* self)
PyObject_ClearWeakRefs((PyObject*)self);
}
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
/*
@ -383,8 +383,7 @@ static int pysqlite_check_remaining_sql(const char* tail)
}
PyTypeObject pysqlite_StatementType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
MODULE_NAME ".Statement", /* tp_name */
sizeof(pysqlite_Statement), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -1689,7 +1689,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
#endif
/* get pointer to string buffer */
buffer = string->ob_type->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");

View File

@ -72,7 +72,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args);
static int check_socket_and_wait_for_timeout(PySocketSockObject *s,
int writing);
#define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type)
#define PySSLObject_Check(v) (Py_Type(v) == &PySSL_Type)
typedef enum {
SOCKET_IS_NONBLOCKING,
@ -570,8 +570,7 @@ static PyObject *PySSL_getattr(PySSLObject *self, char *name)
}
static PyTypeObject PySSL_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"socket.SSL", /*tp_name*/
sizeof(PySSLObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -632,7 +631,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg)
if (!PyString_Check(arg))
return PyErr_Format(PyExc_TypeError,
"RAND_egd() expected string, found %s",
arg->ob_type->tp_name);
Py_Type(arg)->tp_name);
bytes = RAND_egd(PyString_AS_STRING(arg));
if (bytes == -1) {
PyErr_SetString(PySSLErrorObject,
@ -678,7 +677,7 @@ init_ssl(void)
{
PyObject *m, *d;
PySSL_Type.ob_type = &PyType_Type;
Py_Type(&PySSL_Type) = &PyType_Type;
m = Py_InitModule3("_ssl", PySSL_methods, module_doc);
if (m == NULL)

View File

@ -72,7 +72,7 @@ typedef struct {
#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType)
#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStructType)
#define PyStruct_CheckExact(op) (Py_Type(op) == &PyStructType)
/* Exception */
@ -133,7 +133,7 @@ get_pylong(PyObject *v)
Py_INCREF(v);
return v;
}
m = v->ob_type->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);
s->ob_type->tp_free((PyObject *)s);
Py_Type(s)->tp_free((PyObject *)s);
}
static PyObject *
@ -1806,8 +1806,7 @@ static PyGetSetDef s_getsetlist[] = {
static
PyTypeObject PyStructType = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"Struct",
sizeof(PyStructObject),
0,
@ -1857,7 +1856,7 @@ init_struct(void)
if (m == NULL)
return;
PyStructType.ob_type = &PyType_Type;
Py_Type(&PyStructType) = &PyType_Type;
if (PyType_Ready(&PyStructType) < 0)
return;

View File

@ -839,8 +839,7 @@ static void test_structmembers_free(PyObject *ob){
}
static PyTypeObject test_structmembersType = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"test_structmembersType",
sizeof(test_structmembers), /* tp_basicsize */
0, /* tp_itemsize */
@ -890,7 +889,7 @@ init_testcapi(void)
if (m == NULL)
return;
test_structmembersType.ob_type=&PyType_Type;
Py_Type(&test_structmembersType)=&PyType_Type;
Py_INCREF(&test_structmembersType);
PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType);

View File

@ -262,12 +262,12 @@ typedef struct {
Tcl_ObjType *StringType;
} TkappObject;
#define Tkapp_Check(v) ((v)->ob_type == &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, ((PyObject *) v)->ob_refcnt))
(void *) v, Py_Refcnt(v)))
@ -2420,8 +2420,7 @@ Tktt_GetAttr(PyObject *self, char *name)
static PyTypeObject Tktt_Type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"tktimertoken", /*tp_name */
sizeof(TkttObject), /*tp_basicsize */
0, /*tp_itemsize */
@ -2765,8 +2764,7 @@ Tkapp_GetAttr(PyObject *self, char *name)
static PyTypeObject Tkapp_Type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"tkapp", /*tp_name */
sizeof(TkappObject), /*tp_basicsize */
0, /*tp_itemsize */
@ -3105,7 +3103,7 @@ init_tkinter(void)
{
PyObject *m, *d;
Tkapp_Type.ob_type = &PyType_Type;
Py_Type(&Tkapp_Type) = &PyType_Type;
#ifdef WITH_THREAD
tcl_lock = PyThread_allocate_lock();
@ -3133,10 +3131,10 @@ init_tkinter(void)
PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type);
Tktt_Type.ob_type = &PyType_Type;
Py_Type(&Tktt_Type) = &PyType_Type;
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
PyTclObject_Type.ob_type = &PyType_Type;
Py_Type(&PyTclObject_Type) = &PyType_Type;
PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type);
#ifdef TK_AQUA

View File

@ -33,8 +33,7 @@ static PyGetSetDef helper_getset[] = {
};
static PyTypeObject HelperType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"_types.Helper", /* tp_name */
sizeof(Helper), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -14,7 +14,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *object)
{
PyObject *result = NULL;
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
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(object->ob_type)) {
if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) {
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list);

View File

@ -39,7 +39,7 @@ typedef struct arrayobject {
static PyTypeObject Arraytype;
#define array_Check(op) PyObject_TypeCheck(op, &Arraytype)
#define array_CheckExact(op) ((op)->ob_type == &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 &&
self->ob_size < newsize + 16 &&
Py_Size(self) < newsize + 16 &&
self->ob_item != NULL) {
self->ob_size = 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) + (self->ob_size < 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;
self->ob_size = 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;
}
op->ob_size = 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<ap->ob_size);
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 = self->ob_size;
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);
op->ob_type->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 (va->ob_size != wa->ob_size && (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 < va->ob_size && i < wa->ob_size; 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 = va->ob_size;
Py_ssize_t ws = wa->ob_size;
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 a->ob_size;
return Py_Size(a);
}
static PyObject *
array_item(arrayobject *a, Py_ssize_t i)
{
if (i < 0 || i >= a->ob_size) {
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 > a->ob_size)
ilow = a->ob_size;
else if (ilow > Py_Size(a))
ilow = Py_Size(a);
if (ihigh < 0)
ihigh = 0;
if (ihigh < ilow)
ihigh = ilow;
else if (ihigh > a->ob_size)
ihigh = a->ob_size;
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, a->ob_size);
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",
bb->ob_type->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 = a->ob_size + b->ob_size;
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, a->ob_size*a->ob_descr->itemsize);
memcpy(np->ob_item + a->ob_size*a->ob_descr->itemsize,
b->ob_item, b->ob_size*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 = a->ob_size * n;
size = Py_Size(a) * n;
np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
if (np == NULL)
return NULL;
p = np->ob_item;
nbytes = a->ob_size * 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 = b->ob_size;
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",
v->ob_type->tp_name);
Py_Type(v)->tp_name);
return -1;
}
if (ilow < 0)
ilow = 0;
else if (ilow > a->ob_size)
ilow = a->ob_size;
else if (ilow > Py_Size(a))
ilow = Py_Size(a);
if (ihigh < 0)
ihigh = 0;
if (ihigh < ilow)
ihigh = ilow;
else if (ihigh > a->ob_size)
ihigh = a->ob_size;
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,
(a->ob_size-ihigh)*a->ob_descr->itemsize);
a->ob_size += d;
PyMem_RESIZE(item, char, a->ob_size*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 = a->ob_size;
a->allocated = Py_Size(a);
}
else if (d > 0) { /* Insert d items */
PyMem_RESIZE(item, char,
(a->ob_size + 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,
(a->ob_size-ihigh)*a->ob_descr->itemsize);
(Py_Size(a)-ihigh)*a->ob_descr->itemsize);
a->ob_item = item;
a->ob_size += d;
a->allocated = a->ob_size;
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 >= a->ob_size) {
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) self->ob_size, 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 = self->ob_size + b->ob_size;
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 + self->ob_size*self->ob_descr->itemsize,
b->ob_item, b->ob_size*b->ob_descr->itemsize);
self->ob_size = 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\")",
bb->ob_type->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 (self->ob_size > 0) {
if (Py_Size(self) > 0) {
if (n < 0)
n = 0;
items = self->ob_item;
size = self->ob_size * self->ob_descr->itemsize;
size = Py_Size(self) * self->ob_descr->itemsize;
if (n == 0) {
PyMem_FREE(items);
self->ob_item = NULL;
self->ob_size = 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;
self->ob_size *= n;
self->allocated = self->ob_size;
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 < self->ob_size; 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 < self->ob_size; 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 < self->ob_size; 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 < self->ob_size; 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 (self->ob_size == 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 += self->ob_size;
if (i < 0 || i >= self->ob_size) {
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)(self->ob_size)));
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) self->ob_size, 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 = self->ob_size; --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 = self->ob_size; --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 = self->ob_size; --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 (array->ob_size > 0) {
if (Py_Size(array) > 0) {
result = Py_BuildValue("O(cs#)O",
array->ob_type,
Py_Type(array),
array->ob_descr->typecode,
array->ob_item,
array->ob_size * array->ob_descr->itemsize,
Py_Size(array) * array->ob_descr->itemsize,
dict);
} else {
result = Py_BuildValue("O(c)O",
array->ob_type,
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 (self->ob_size > 1) {
if (Py_Size(self) > 1) {
for (p = self->ob_item,
q = self->ob_item + (self->ob_size - 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 = self->ob_size + 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;
self->ob_size += n;
self->allocated = self->ob_size;
nread = fread(item + (self->ob_size - 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) {
self->ob_size -= (n - nread);
PyMem_RESIZE(item, char, self->ob_size*itemsize);
Py_Size(self) -= (n - nread);
PyMem_RESIZE(item, char, Py_Size(self)*itemsize);
self->ob_item = item;
self->allocated = self->ob_size;
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, (self->ob_size + n) * itemsize);
PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize);
if (item == NULL) {
PyErr_NoMemory();
return NULL;
}
self->ob_item = item;
self->ob_size += n;
self->allocated = self->ob_size;
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,
self->ob_size - n + i, v) != 0) {
self->ob_size -= n;
Py_Size(self) - n + i, v) != 0) {
Py_Size(self) -= n;
PyMem_RESIZE(item, char,
self->ob_size * itemsize);
Py_Size(self) * itemsize);
self->ob_item = item;
self->allocated = self->ob_size;
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(self->ob_size);
PyObject *list = PyList_New(Py_Size(self));
Py_ssize_t i;
if (list == NULL)
return NULL;
for (i = 0; i < self->ob_size; 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, (self->ob_size + n) * itemsize);
PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize);
if (item == NULL) {
PyErr_NoMemory();
return NULL;
}
self->ob_item = item;
self->ob_size += n;
self->allocated = self->ob_size;
memcpy(item + (self->ob_size - 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,
self->ob_size * 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, self->ob_size + n);
PyMem_RESIZE(item, Py_UNICODE, Py_Size(self) + n);
if (item == NULL) {
PyErr_NoMemory();
return NULL;
}
self->ob_item = (char *) item;
self->ob_size += n;
self->allocated = self->ob_size;
memcpy(item + self->ob_size - 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, self->ob_size);
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 = a->ob_size;
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 += self->ob_size;
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, self->ob_size,
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
&start, &stop, &step, &slicelength) < 0) {
return NULL;
}
@ -1636,14 +1636,14 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
if (i==-1 && PyErr_Occurred())
return -1;
if (i < 0)
i += self->ob_size;
i += Py_Size(self);
return array_ass_item(self, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelength;
int itemsize = self->ob_descr->itemsize;
if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size,
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
&start, &stop, &step, &slicelength) < 0) {
return -1;
}
@ -1671,17 +1671,17 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
self->ob_item + (cur + 1)*itemsize,
(step - 1) * itemsize);
}
extra = self->ob_size - (cur + 1);
extra = Py_Size(self) - (cur + 1);
if (extra > 0) {
memmove(self->ob_item + (cur - i)*itemsize,
self->ob_item + (cur + 1)*itemsize,
extra*itemsize);
}
self->ob_size -= slicelength;
Py_Size(self) -= slicelength;
self->ob_item = (char *)PyMem_REALLOC(self->ob_item,
itemsize*self->ob_size);
self->allocated = self->ob_size;
itemsize*Py_Size(self));
self->allocated = Py_Size(self);
return 0;
}
@ -1693,16 +1693,16 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
if (!array_Check(value)) {
PyErr_Format(PyExc_TypeError,
"must assign array (not \"%.200s\") to slice",
value->ob_type->tp_name);
Py_Type(value)->tp_name);
return -1;
}
av = (arrayobject*)value;
if (av->ob_size != slicelength) {
if (Py_Size(av) != slicelength) {
PyErr_Format(PyExc_ValueError,
"attempt to assign array of size %ld to extended slice of size %ld",
/*XXX*/(long)av->ob_size, /*XXX*/(long)slicelength);
/*XXX*/(long)Py_Size(av), /*XXX*/(long)slicelength);
return -1;
}
@ -1711,7 +1711,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
/* protect against a[::-1] = a */
if (self == av) {
value = array_slice(av, 0, av->ob_size);
value = array_slice(av, 0, Py_Size(av));
av = (arrayobject*)value;
if (!av)
return -1;
@ -1758,7 +1758,7 @@ array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
*ptr = (void *)self->ob_item;
if (*ptr == NULL)
*ptr = emptybuf;
return self->ob_size*self->ob_descr->itemsize;
return Py_Size(self)*self->ob_descr->itemsize;
}
static Py_ssize_t
@ -1772,14 +1772,14 @@ array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
*ptr = (void *)self->ob_item;
if (*ptr == NULL)
*ptr = emptybuf;
return self->ob_size*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 = self->ob_size*self->ob_descr->itemsize;
*lenp = Py_Size(self)*self->ob_descr->itemsize;
return 1;
}
@ -1888,9 +1888,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
self->ob_item = item;
self->ob_size = n / sizeof(Py_UNICODE);
Py_Size(self) = n / sizeof(Py_UNICODE);
memcpy(item, PyUnicode_AS_DATA(initial), n);
self->allocated = self->ob_size;
self->allocated = Py_Size(self);
}
#endif
}
@ -1978,8 +1978,7 @@ itemsize -- the length in bytes of one array item\n\
static PyObject *array_iter(arrayobject *ao);
static PyTypeObject Arraytype = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"array.array",
sizeof(arrayobject),
0,
@ -2060,7 +2059,7 @@ static PyObject *
arrayiter_next(arrayiterobject *it)
{
assert(PyArrayIter_Check(it));
if (it->index < it->ao->ob_size)
if (it->index < Py_Size(it->ao))
return (*it->getitem)(it->ao, it->index++);
return NULL;
}
@ -2081,8 +2080,7 @@ arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg)
}
static PyTypeObject PyArrayIter_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"arrayiterator", /* tp_name */
sizeof(arrayiterobject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -41,7 +41,7 @@ typedef fpos_t Py_off_t;
#define MODE_READ_EOF 2
#define MODE_WRITE 3
#define BZ2FileObject_Check(v) ((v)->ob_type == &BZ2File_Type)
#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type)
#ifdef BZ_CONFIG_ERROR
@ -1418,7 +1418,7 @@ BZ2File_dealloc(BZ2FileObject *self)
}
Util_DropReadAhead(self);
Py_XDECREF(self->file);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
/* This is a hacked version of Python's fileobject.c:file_getiter(). */
@ -1480,8 +1480,7 @@ newlines are available only when reading.\n\
;
static PyTypeObject BZ2File_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"bz2.BZ2File", /*tp_name*/
sizeof(BZ2FileObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -1735,7 +1734,7 @@ BZ2Comp_dealloc(BZ2CompObject *self)
PyThread_free_lock(self->lock);
#endif
BZ2_bzCompressEnd(&self->bzs);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
@ -1752,8 +1751,7 @@ must be a number between 1 and 9.\n\
");
static PyTypeObject BZ2Comp_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"bz2.BZ2Compressor", /*tp_name*/
sizeof(BZ2CompObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -1958,7 +1956,7 @@ BZ2Decomp_dealloc(BZ2DecompObject *self)
#endif
Py_XDECREF(self->unused_data);
BZ2_bzDecompressEnd(&self->bzs);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
@ -1974,8 +1972,7 @@ decompress() function instead.\n\
");
static PyTypeObject BZ2Decomp_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"bz2.BZ2Decompressor", /*tp_name*/
sizeof(BZ2DecompObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -2209,9 +2206,9 @@ initbz2(void)
{
PyObject *m;
BZ2File_Type.ob_type = &PyType_Type;
BZ2Comp_Type.ob_type = &PyType_Type;
BZ2Decomp_Type.ob_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)

View File

@ -151,12 +151,12 @@ Pdata_dealloc(Pdata *self)
}
static PyTypeObject PdataType = {
PyObject_HEAD_INIT(NULL) 0, "cPickle.Pdata", sizeof(Pdata), 0,
PyVarObject_HEAD_INIT(NULL, 0) "cPickle.Pdata", sizeof(Pdata), 0,
(destructor)Pdata_dealloc,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0L,0L,0L,0L, ""
};
#define Pdata_Check(O) ((O)->ob_type == &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 (self->arg->ob_refcnt > 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 (ob->ob_refcnt < 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",
obj->ob_type->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 = args->ob_type;
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 (args->ob_refcnt > 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);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
static int
@ -3037,8 +3037,7 @@ PyDoc_STRVAR(Picklertype__doc__,
"Objects that know how to pickle objects\n");
static PyTypeObject Picklertype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"cPickle.Pickler", /*tp_name*/
sizeof(Picklerobject), /*tp_basicsize*/
0,
@ -5254,7 +5253,7 @@ Unpickler_dealloc(Unpicklerobject *self)
free(self->buf);
}
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
static int
@ -5483,8 +5482,7 @@ PyDoc_STRVAR(Unpicklertype__doc__,
"Objects that know how to unpickle");
static PyTypeObject Unpicklertype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"cPickle.Unpickler", /*tp_name*/
sizeof(Unpicklerobject), /*tp_basicsize*/
0,
@ -5708,9 +5706,9 @@ initcPickle(void)
PyObject *format_version;
PyObject *compatible_formats;
Picklertype.ob_type = &PyType_Type;
Unpicklertype.ob_type = &PyType_Type;
PdataType.ob_type = &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. :(

View File

@ -514,8 +514,7 @@ O_dealloc(Oobject *self) {
PyDoc_STRVAR(Otype__doc__, "Simple type for output to strings.");
static PyTypeObject Otype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"cStringIO.StringO", /*tp_name*/
sizeof(Oobject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -635,8 +634,7 @@ PyDoc_STRVAR(Itype__doc__,
"Simple type for treating strings as input file streams");
static PyTypeObject Itype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"cStringIO.StringI", /*tp_name*/
sizeof(Iobject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -746,8 +744,8 @@ initcStringIO(void) {
d = PyModule_GetDict(m);
/* Export C API */
Itype.ob_type=&PyType_Type;
Otype.ob_type=&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",

View File

@ -670,8 +670,7 @@ multibytecodec_dealloc(MultibyteCodecObject *self)
}
static PyTypeObject MultibyteCodec_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"MultibyteCodec", /* tp_name */
sizeof(MultibyteCodecObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -946,12 +945,11 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self)
{
PyObject_GC_UnTrack(self);
ERROR_DECREF(self->errors);
self->ob_type->tp_free(self);
Py_Type(self)->tp_free(self);
}
static PyTypeObject MultibyteIncrementalEncoder_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"MultibyteIncrementalEncoder", /* tp_name */
sizeof(MultibyteIncrementalEncoderObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1147,12 +1145,11 @@ mbidecoder_dealloc(MultibyteIncrementalDecoderObject *self)
{
PyObject_GC_UnTrack(self);
ERROR_DECREF(self->errors);
self->ob_type->tp_free(self);
Py_Type(self)->tp_free(self);
}
static PyTypeObject MultibyteIncrementalDecoder_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"MultibyteIncrementalDecoder", /* tp_name */
sizeof(MultibyteIncrementalDecoderObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1464,12 +1461,11 @@ mbstreamreader_dealloc(MultibyteStreamReaderObject *self)
PyObject_GC_UnTrack(self);
ERROR_DECREF(self->errors);
Py_DECREF(self->stream);
self->ob_type->tp_free(self);
Py_Type(self)->tp_free(self);
}
static PyTypeObject MultibyteStreamReader_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"MultibyteStreamReader", /* tp_name */
sizeof(MultibyteStreamReaderObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1667,7 +1663,7 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self)
PyObject_GC_UnTrack(self);
ERROR_DECREF(self->errors);
Py_DECREF(self->stream);
self->ob_type->tp_free(self);
Py_Type(self)->tp_free(self);
}
static struct PyMethodDef mbstreamwriter_methods[] = {
@ -1688,8 +1684,7 @@ static PyMemberDef mbstreamwriter_members[] = {
};
static PyTypeObject MultibyteStreamWriter_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"MultibyteStreamWriter", /* tp_name */
sizeof(MultibyteStreamWriterObject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -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'",
p->ob_type->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, u->ob_type->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'",
result->ob_type->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",
a->ob_type->tp_name, b->ob_type->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, num->ob_type->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)",
self->ob_type->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)",
self->ob_type->tp_name,
Py_Type(self)->tp_name,
GET_TD_DAYS(self),
GET_TD_SECONDS(self));
return PyString_FromFormat("%s(%d)",
self->ob_type->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", self->ob_type, delta_getstate(self));
return Py_BuildValue("ON", Py_Type(self), delta_getstate(self));
}
#define OFFSET(field) offsetof(PyDateTime_Delta, field)
@ -2125,8 +2125,7 @@ static PyNumberMethods delta_as_number = {
};
static PyTypeObject PyDateTime_DeltaType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"datetime.timedelta", /* tp_name */
sizeof(PyDateTime_Delta), /* tp_basicsize */
0, /* tp_itemsize */
@ -2415,7 +2414,7 @@ date_repr(PyDateTime_Date *self)
char buffer[1028];
const char *type_name;
type_name = self->ob_type->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));
@ -2555,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(self->ob_type, tuple, NULL);
clone = date_new(Py_Type(self), tuple, NULL);
Py_DECREF(tuple);
return clone;
}
@ -2605,7 +2604,7 @@ date_getstate(PyDateTime_Date *self)
static PyObject *
date_reduce(PyDateTime_Date *self, PyObject *arg)
{
return Py_BuildValue("(ON)", self->ob_type, date_getstate(self));
return Py_BuildValue("(ON)", Py_Type(self), date_getstate(self));
}
static PyMethodDef date_methods[] = {
@ -2683,8 +2682,7 @@ static PyNumberMethods date_as_number = {
};
static PyTypeObject PyDateTime_DateType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"datetime.date", /* tp_name */
sizeof(PyDateTime_Date), /* tp_basicsize */
0, /* tp_itemsize */
@ -2908,10 +2906,10 @@ tzinfo_reduce(PyObject *self)
if (state == Py_None) {
Py_DECREF(state);
return Py_BuildValue("(ON)", self->ob_type, args);
return Py_BuildValue("(ON)", Py_Type(self), args);
}
else
return Py_BuildValue("(ONN)", self->ob_type, args, state);
return Py_BuildValue("(ONN)", Py_Type(self), args, state);
}
static PyMethodDef tzinfo_methods[] = {
@ -3106,7 +3104,7 @@ time_dealloc(PyDateTime_Time *self)
if (HASTZINFO(self)) {
Py_XDECREF(self->tzinfo);
}
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
/*
@ -3140,7 +3138,7 @@ static PyObject *
time_repr(PyDateTime_Time *self)
{
char buffer[100];
const char *type_name = self->ob_type->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);
@ -3354,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(self->ob_type, tuple, NULL);
clone = time_new(Py_Type(self), tuple, NULL);
Py_DECREF(tuple);
return clone;
}
@ -3408,7 +3406,7 @@ time_getstate(PyDateTime_Time *self)
static PyObject *
time_reduce(PyDateTime_Time *self, PyObject *arg)
{
return Py_BuildValue("(ON)", self->ob_type, time_getstate(self));
return Py_BuildValue("(ON)", Py_Type(self), time_getstate(self));
}
static PyMethodDef time_methods[] = {
@ -3902,7 +3900,7 @@ datetime_dealloc(PyDateTime_DateTime *self)
if (HASTZINFO(self)) {
Py_XDECREF(self->tzinfo);
}
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
/*
@ -4051,7 +4049,7 @@ static PyObject *
datetime_repr(PyDateTime_DateTime *self)
{
char buffer[1000];
const char *type_name = self->ob_type->tp_name;
const char *type_name = Py_Type(self)->tp_name;
PyObject *baserepr;
if (DATE_GET_MICROSECOND(self)) {
@ -4272,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(self->ob_type, tuple, NULL);
clone = datetime_new(Py_Type(self), tuple, NULL);
Py_DECREF(tuple);
return clone;
}
@ -4460,7 +4458,7 @@ datetime_getstate(PyDateTime_DateTime *self)
static PyObject *
datetime_reduce(PyDateTime_DateTime *self, PyObject *arg)
{
return Py_BuildValue("(ON)", self->ob_type, datetime_getstate(self));
return Py_BuildValue("(ON)", Py_Type(self), datetime_getstate(self));
}
static PyMethodDef datetime_methods[] = {

View File

@ -36,7 +36,7 @@ typedef struct {
static PyTypeObject Dbmtype;
#define is_dbmobject(v) ((v)->ob_type == &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; }
@ -302,8 +302,7 @@ dbm_getattr(dbmobject *dp, char *name)
}
static PyTypeObject Dbmtype = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"dbm.dbm",
sizeof(dbmobject),
0,

View File

@ -62,7 +62,7 @@ dl_sym(dlobject *xp, PyObject *args)
name = PyString_AS_STRING(args);
} else {
PyErr_Format(PyExc_TypeError, "expected string, found %.200s",
args->ob_type->tp_name);
Py_Type(args)->tp_name);
return NULL;
}
func = dlsym(xp->dl_handle, name);
@ -141,8 +141,7 @@ dl_getattr(dlobject *xp, char *name)
static PyTypeObject Dltype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"dl.dl", /*tp_name*/
sizeof(dlobject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -237,7 +236,7 @@ initdl(void)
PyObject *m, *d, *x;
/* Initialize object type */
Dltype.ob_type = &PyType_Type;
Py_Type(&Dltype) = &PyType_Type;
/* Create the module and add the functions */
m = Py_InitModule("dl", dl_methods);

View File

@ -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 = FROM_GC(gc)->ob_refcnt;
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 = FROM_GC(gc)->ob_type->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 = op->ob_type->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 = FROM_GC(gc)->ob_type->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(op->ob_type))
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, op->ob_type->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 = op->ob_type->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 = obj->ob_type->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 = obj->ob_type->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(op->ob_type, 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);
op->ob_size = nitems;
Py_Size(op) = nitems;
return op;
}

View File

@ -36,7 +36,7 @@ typedef struct {
static PyTypeObject Dbmtype;
#define is_dbmobject(v) ((v)->ob_type == &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; }
@ -370,8 +370,7 @@ dbm_getattr(dbmobject *dp, char *name)
}
static PyTypeObject Dbmtype = {
PyObject_HEAD_INIT(0)
0,
PyVarObject_HEAD_INIT(0, 0)
"gdbm.gdbm",
sizeof(dbmobject),
0,

View File

@ -59,7 +59,7 @@ groupby_dealloc(groupbyobject *gbo)
Py_XDECREF(gbo->tgtkey);
Py_XDECREF(gbo->currkey);
Py_XDECREF(gbo->currvalue);
gbo->ob_type->tp_free(gbo);
Py_Type(gbo)->tp_free(gbo);
}
static int
@ -139,8 +139,7 @@ PyDoc_STRVAR(groupby_doc,
(key, sub-iterator) grouped by each value of key(value).\n");
static PyTypeObject groupby_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.groupby", /* tp_name */
sizeof(groupbyobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -261,8 +260,7 @@ _grouper_next(_grouperobject *igo)
}
static PyTypeObject _grouper_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools._grouper", /* tp_name */
sizeof(_grouperobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -415,8 +413,7 @@ teedataobject_dealloc(teedataobject *tdo)
PyDoc_STRVAR(teedataobject_doc, "Data container common to multiple tee objects.");
static PyTypeObject teedataobject_type = {
PyObject_HEAD_INIT(0) /* Must fill in type value later */
0, /* ob_size */
PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */
"itertools.tee_dataobject", /* tp_name */
sizeof(teedataobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -572,8 +569,7 @@ static PyMethodDef tee_methods[] = {
};
static PyTypeObject tee_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.tee", /* tp_name */
sizeof(teeobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -718,7 +714,7 @@ cycle_dealloc(cycleobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->saved);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -768,8 +764,7 @@ Return elements from the iterable until it is exhausted.\n\
Then repeat the sequence indefinitely.");
static PyTypeObject cycle_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.cycle", /* tp_name */
sizeof(cycleobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -862,7 +857,7 @@ dropwhile_dealloc(dropwhileobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->func);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -882,7 +877,7 @@ dropwhile_next(dropwhileobject *lz)
PyObject *(*iternext)(PyObject *);
assert(PyIter_Check(it));
iternext = *it->ob_type->tp_iternext;
iternext = *Py_Type(it)->tp_iternext;
for (;;) {
item = iternext(it);
if (item == NULL)
@ -912,8 +907,7 @@ Drop items from the iterable while predicate(item) is true.\n\
Afterwards, return every element until the iterable is exhausted.");
static PyTypeObject dropwhile_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.dropwhile", /* tp_name */
sizeof(dropwhileobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1006,7 +1000,7 @@ takewhile_dealloc(takewhileobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->func);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1028,7 +1022,7 @@ takewhile_next(takewhileobject *lz)
return NULL;
assert(PyIter_Check(it));
item = (*it->ob_type->tp_iternext)(it);
item = (*Py_Type(it)->tp_iternext)(it);
if (item == NULL)
return NULL;
@ -1053,8 +1047,7 @@ Return successive entries from an iterable as long as the \n\
predicate evaluates to true for each entry.");
static PyTypeObject takewhile_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.takewhile", /* tp_name */
sizeof(takewhileobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1197,7 +1190,7 @@ islice_dealloc(isliceobject *lz)
{
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1216,7 +1209,7 @@ islice_next(isliceobject *lz)
PyObject *(*iternext)(PyObject *);
assert(PyIter_Check(it));
iternext = *it->ob_type->tp_iternext;
iternext = *Py_Type(it)->tp_iternext;
while (lz->cnt < lz->next) {
item = iternext(it);
if (item == NULL)
@ -1249,8 +1242,7 @@ skipped between successive calls. Works like a slice() on a list\n\
but returns an iterator.");
static PyTypeObject islice_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.islice", /* tp_name */
sizeof(isliceobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1341,7 +1333,7 @@ starmap_dealloc(starmapobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->func);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1360,7 +1352,7 @@ starmap_next(starmapobject *lz)
PyObject *it = lz->it;
assert(PyIter_Check(it));
args = (*it->ob_type->tp_iternext)(it);
args = (*Py_Type(it)->tp_iternext)(it);
if (args == NULL)
return NULL;
if (!PyTuple_CheckExact(args)) {
@ -1381,8 +1373,7 @@ Return an iterator whose values are returned from the function evaluated\n\
with a argument tuple taken from the given sequence.");
static PyTypeObject starmap_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.starmap", /* tp_name */
sizeof(starmapobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1487,7 +1478,7 @@ imap_dealloc(imapobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->iters);
Py_XDECREF(lz->func);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1561,8 +1552,7 @@ iterable is exhausted instead of filling in None for shorter\n\
iterables.");
static PyTypeObject imap_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.imap", /* tp_name */
sizeof(imapobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1666,7 +1656,7 @@ chain_dealloc(chainobject *lz)
{
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->ittuple);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1706,8 +1696,7 @@ first iterable until it is exhausted, then elements from the next\n\
iterable, until all of the iterables are exhausted.");
static PyTypeObject chain_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.chain", /* tp_name */
sizeof(chainobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1798,7 +1787,7 @@ ifilter_dealloc(ifilterobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->func);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1818,7 +1807,7 @@ ifilter_next(ifilterobject *lz)
PyObject *(*iternext)(PyObject *);
assert(PyIter_Check(it));
iternext = *it->ob_type->tp_iternext;
iternext = *Py_Type(it)->tp_iternext;
for (;;) {
item = iternext(it);
if (item == NULL)
@ -1850,8 +1839,7 @@ Return those items of sequence for which function(item) is true.\n\
If function is None, return the items that are true.");
static PyTypeObject ifilter_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.ifilter", /* tp_name */
sizeof(ifilterobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1943,7 +1931,7 @@ ifilterfalse_dealloc(ifilterfalseobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->func);
Py_XDECREF(lz->it);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -1963,7 +1951,7 @@ ifilterfalse_next(ifilterfalseobject *lz)
PyObject *(*iternext)(PyObject *);
assert(PyIter_Check(it));
iternext = *it->ob_type->tp_iternext;
iternext = *Py_Type(it)->tp_iternext;
for (;;) {
item = iternext(it);
if (item == NULL)
@ -1995,8 +1983,7 @@ Return those items of sequence for which function(item) is false.\n\
If function is None, return the items that are false.");
static PyTypeObject ifilterfalse_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.ifilterfalse", /* tp_name */
sizeof(ifilterfalseobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2094,8 +2081,7 @@ Return a count object whose .next() method returns consecutive\n\
integers starting from zero or, if specified, from firstval.");
static PyTypeObject count_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.count", /* tp_name */
sizeof(countobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2214,7 +2200,7 @@ izip_dealloc(izipobject *lz)
PyObject_GC_UnTrack(lz);
Py_XDECREF(lz->ittuple);
Py_XDECREF(lz->result);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -2237,12 +2223,12 @@ izip_next(izipobject *lz)
if (tuplesize == 0)
return NULL;
if (result->ob_refcnt == 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 = (*it->ob_type->tp_iternext)(it);
item = (*Py_Type(it)->tp_iternext)(it);
if (item == NULL) {
Py_DECREF(result);
return NULL;
@ -2258,7 +2244,7 @@ izip_next(izipobject *lz)
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);
assert(PyIter_Check(it));
item = (*it->ob_type->tp_iternext)(it);
item = (*Py_Type(it)->tp_iternext)(it);
if (item == NULL) {
Py_DECREF(result);
return NULL;
@ -2280,8 +2266,7 @@ function but consumes less memory by returning an iterator instead of\n\
a list.");
static PyTypeObject izip_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.izip", /* tp_name */
sizeof(izipobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2365,7 +2350,7 @@ repeat_dealloc(repeatobject *ro)
{
PyObject_GC_UnTrack(ro);
Py_XDECREF(ro->element);
ro->ob_type->tp_free(ro);
Py_Type(ro)->tp_free(ro);
}
static int
@ -2428,8 +2413,7 @@ for the specified number of times. If not specified, returns the element\n\
endlessly.");
static PyTypeObject repeat_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.repeat", /* tp_name */
sizeof(repeatobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2561,7 +2545,7 @@ izip_longest_dealloc(iziplongestobject *lz)
Py_XDECREF(lz->ittuple);
Py_XDECREF(lz->result);
Py_XDECREF(lz->fillvalue);
lz->ob_type->tp_free(lz);
Py_Type(lz)->tp_free(lz);
}
static int
@ -2587,7 +2571,7 @@ izip_longest_next(iziplongestobject *lz)
return NULL;
if (lz->numactive == 0)
return NULL;
if (result->ob_refcnt == 1) {
if (Py_Refcnt(result) == 1) {
Py_INCREF(result);
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);
@ -2596,7 +2580,7 @@ izip_longest_next(iziplongestobject *lz)
item = lz->fillvalue;
} else {
assert(PyIter_Check(it));
item = (*it->ob_type->tp_iternext)(it);
item = (*Py_Type(it)->tp_iternext)(it);
if (item == NULL) {
lz->numactive -= 1;
if (lz->numactive == 0) {
@ -2625,7 +2609,7 @@ izip_longest_next(iziplongestobject *lz)
item = lz->fillvalue;
} else {
assert(PyIter_Check(it));
item = (*it->ob_type->tp_iternext)(it);
item = (*Py_Type(it)->tp_iternext)(it);
if (item == NULL) {
lz->numactive -= 1;
if (lz->numactive == 0) {
@ -2657,8 +2641,7 @@ defaults to None or can be specified by a keyword argument.\n\
");
static PyTypeObject iziplongest_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"itertools.izip_longest", /* tp_name */
sizeof(iziplongestobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2757,7 +2740,7 @@ inititertools(void)
NULL
};
teedataobject_type.ob_type = &PyType_Type;
Py_Type(&teedataobject_type) = &PyType_Type;
m = Py_InitModule3("itertools", module_methods, module_doc);
if (m == NULL)
return;

View File

@ -441,8 +441,7 @@ lad_getattr(lad_t *xp, char *name)
}
static PyTypeObject Ladtype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"linuxaudiodev.linux_audio_device", /*tp_name*/
sizeof(lad_t), /*tp_size*/
0, /*tp_itemsize*/

View File

@ -221,8 +221,7 @@ hexdigest() -- return the current digest as a string of hexadecimal digits\n\
copy() -- return a copy of the current md5 object");
static PyTypeObject MD5type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_md5.md5", /*tp_name*/
sizeof(md5object), /*tp_size*/
0, /*tp_itemsize*/
@ -299,7 +298,7 @@ init_md5(void)
{
PyObject *m, *d;
MD5type.ob_type = &PyType_Type;
Py_Type(&MD5type) = &PyType_Type;
if (PyType_Ready(&MD5type) < 0)
return;
m = Py_InitModule3("_md5", md5_functions, module_doc);

View File

@ -782,8 +782,7 @@ static PyBufferProcs mmap_as_buffer = {
};
static PyTypeObject mmap_object_type = {
PyObject_HEAD_INIT(0) /* patched in module init */
0, /* ob_size */
PyVarObject_HEAD_INIT(0, 0) /* patched in module init */
"mmap.mmap", /* tp_name */
sizeof(mmap_object), /* tp_size */
0, /* tp_itemsize */
@ -1141,7 +1140,7 @@ PyMODINIT_FUNC
PyObject *dict, *module;
/* Patch the object type */
mmap_object_type.ob_type = &PyType_Type;
Py_Type(&mmap_object_type) = &PyType_Type;
module = Py_InitModule("mmap", mmap_functions);
if (module == NULL)

View File

@ -397,8 +397,7 @@ After, f=itemgetter(2), the call f(r) returns r[2].\n\
After, g=itemgetter(2,5,3), the call g(r) returns (r[2], r[5], r[3])");
static PyTypeObject itemgetter_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"operator.itemgetter", /* tp_name */
sizeof(itemgetterobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -535,8 +534,7 @@ After, f=attrgetter('name'), the call f(r) returns r.name.\n\
After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).");
static PyTypeObject attrgetter_type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
PyVarObject_HEAD_INIT(NULL, 0)
"operator.attrgetter", /* tp_name */
sizeof(attrgetterobject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -841,8 +841,7 @@ oss_mixer_getattr(oss_mixer_t *self, char *name)
}
static PyTypeObject OSSAudioType = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"ossaudiodev.oss_audio_device", /*tp_name*/
sizeof(oss_audio_t), /*tp_size*/
0, /*tp_itemsize*/
@ -856,8 +855,7 @@ static PyTypeObject OSSAudioType = {
};
static PyTypeObject OSSMixerType = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"ossaudiodev.oss_mixer_device", /*tp_name*/
sizeof(oss_mixer_t), /*tp_size*/
0, /*tp_itemsize*/

View File

@ -166,8 +166,7 @@ static PyObject *parser_getattr(PyObject *self, char *name);
static
PyTypeObject PyST_Type = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"parser.st", /* tp_name */
(int) sizeof(PyST_Object), /* tp_basicsize */
0, /* tp_itemsize */
@ -694,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",
temp->ob_type->tp_name);
Py_Type(temp)->tp_name);
Py_DECREF(temp);
return 0;
}
@ -707,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",
temp->ob_type->tp_name);
Py_Type(temp)->tp_name);
Py_DECREF(o);
Py_DECREF(temp);
return 0;
@ -3233,7 +3232,7 @@ initparser(void)
{
PyObject *module, *copyreg;
PyST_Type.ob_type = &PyType_Type;
Py_Type(&PyST_Type) = &PyType_Type;
module = Py_InitModule("parser", parser_functions);
if (module == NULL)
return;

View File

@ -2593,7 +2593,7 @@ extract_time(PyObject *t, long* sec, long* usec)
long intval;
if (PyFloat_Check(t)) {
double tval = PyFloat_AsDouble(t);
PyObject *intobj = t->ob_type->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);

View File

@ -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)",
str->ob_type->tp_name);
Py_Type(str)->tp_name);
goto finally;
}
len = PyString_GET_SIZE(str);
@ -1687,8 +1687,7 @@ xmlparse_clear(xmlparseobject *op)
PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser");
static PyTypeObject Xmlparsetype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"pyexpat.xmlparser", /*tp_name*/
sizeof(xmlparseobject) + PyGC_HEAD_SIZE,/*tp_basicsize*/
0, /*tp_itemsize*/
@ -1860,7 +1859,7 @@ MODULE_INITFUNC(void)
if (modelmod_name == NULL)
return;
Xmlparsetype.ob_type = &PyType_Type;
Py_Type(&Xmlparsetype) = &PyType_Type;
/* Create the module and add the functions */
m = Py_InitModule3(MODULE_NAME, pyexpat_methods,

View File

@ -587,8 +587,7 @@ poll_getattr(pollObject *self, char *name)
static PyTypeObject poll_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"select.poll", /*tp_name*/
sizeof(pollObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -706,7 +705,7 @@ initselect(void)
#else
{
#endif
poll_Type.ob_type = &PyType_Type;
Py_Type(&poll_Type) = &PyType_Type;
PyModule_AddIntConstant(m, "POLLIN", POLLIN);
PyModule_AddIntConstant(m, "POLLPRI", POLLPRI);
PyModule_AddIntConstant(m, "POLLOUT", POLLOUT);

View File

@ -409,7 +409,7 @@ SHA256_copy(SHAobject *self, PyObject *unused)
{
SHAobject *newobj;
if (((PyObject*)self)->ob_type == &SHA256type) {
if (Py_Type(self) == &SHA256type) {
if ( (newobj = newSHA256object())==NULL)
return NULL;
} else {
@ -536,8 +536,7 @@ static PyMemberDef SHA_members[] = {
};
static PyTypeObject SHA224type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_sha256.sha224", /*tp_name*/
sizeof(SHAobject), /*tp_size*/
0, /*tp_itemsize*/
@ -571,8 +570,7 @@ static PyTypeObject SHA224type = {
};
static PyTypeObject SHA256type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_sha256.sha256", /*tp_name*/
sizeof(SHAobject), /*tp_size*/
0, /*tp_itemsize*/
@ -689,10 +687,10 @@ init_sha256(void)
{
PyObject *m;
SHA224type.ob_type = &PyType_Type;
Py_Type(&SHA224type) = &PyType_Type;
if (PyType_Ready(&SHA224type) < 0)
return;
SHA256type.ob_type = &PyType_Type;
Py_Type(&SHA256type) = &PyType_Type;
if (PyType_Ready(&SHA256type) < 0)
return;
m = Py_InitModule("_sha256", SHA_functions);

View File

@ -602,8 +602,7 @@ static PyMemberDef SHA_members[] = {
};
static PyTypeObject SHA384type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_sha512.sha384", /*tp_name*/
sizeof(SHAobject), /*tp_size*/
0, /*tp_itemsize*/
@ -637,8 +636,7 @@ static PyTypeObject SHA384type = {
};
static PyTypeObject SHA512type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_sha512.sha512", /*tp_name*/
sizeof(SHAobject), /*tp_size*/
0, /*tp_itemsize*/
@ -755,10 +753,10 @@ init_sha512(void)
{
PyObject *m;
SHA384type.ob_type = &PyType_Type;
Py_Type(&SHA384type) = &PyType_Type;
if (PyType_Ready(&SHA384type) < 0)
return;
SHA512type.ob_type = &PyType_Type;
Py_Type(&SHA512type) = &PyType_Type;
if (PyType_Ready(&SHA512type) < 0)
return;
m = Py_InitModule("_sha512", SHA_functions);

View File

@ -489,8 +489,7 @@ static PyGetSetDef SHA_getseters[] = {
};
static PyTypeObject SHAtype = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"_sha.sha", /*tp_name*/
sizeof(SHAobject), /*tp_size*/
0, /*tp_itemsize*/
@ -577,7 +576,7 @@ init_sha(void)
{
PyObject *m;
SHAtype.ob_type = &PyType_Type;
Py_Type(&SHAtype) = &PyType_Type;
if (PyType_Ready(&SHAtype) < 0)
return;
m = Py_InitModule("_sha", SHA_functions);

View File

@ -1245,7 +1245,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
PyExc_TypeError,
"getsockaddrarg: "
"AF_NETLINK address must be tuple, not %.500s",
args->ob_type->tp_name);
Py_Type(args)->tp_name);
return 0;
}
if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &pid, &groups))
@ -1268,7 +1268,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
PyExc_TypeError,
"getsockaddrarg: "
"AF_INET address must be tuple, not %.500s",
args->ob_type->tp_name);
Py_Type(args)->tp_name);
return 0;
}
if (!PyArg_ParseTuple(args, "eti:getsockaddrarg",
@ -1298,7 +1298,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
PyExc_TypeError,
"getsockaddrarg: "
"AF_INET6 address must be tuple, not %.500s",
args->ob_type->tp_name);
Py_Type(args)->tp_name);
return 0;
}
if (!PyArg_ParseTuple(args, "eti|ii",
@ -1420,7 +1420,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
PyExc_TypeError,
"getsockaddrarg: "
"AF_PACKET address must be tuple, not %.500s",
args->ob_type->tp_name);
Py_Type(args)->tp_name);
return 0;
}
if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName,
@ -2843,7 +2843,7 @@ sock_dealloc(PySocketSockObject *s)
{
if (s->sock_fd != -1)
(void) SOCKETCLOSE(s->sock_fd);
s->ob_type->tp_free((PyObject *)s);
Py_Type(s)->tp_free((PyObject *)s);
}
@ -2928,8 +2928,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
/* Type object for socket objects. */
static PyTypeObject sock_type = {
PyObject_HEAD_INIT(0) /* Must fill in type value later */
0, /* ob_size */
PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */
"_socket.socket", /* tp_name */
sizeof(PySocketSockObject), /* tp_basicsize */
0, /* tp_itemsize */
@ -3555,7 +3554,7 @@ socket_ntohl(PyObject *self, PyObject *arg)
else
return PyErr_Format(PyExc_TypeError,
"expected int/long, %s found",
arg->ob_type->tp_name);
Py_Type(arg)->tp_name);
if (x == (unsigned long) -1 && PyErr_Occurred())
return NULL;
return PyLong_FromUnsignedLong(ntohl(x));
@ -3624,7 +3623,7 @@ socket_htonl(PyObject *self, PyObject *arg)
else
return PyErr_Format(PyExc_TypeError,
"expected int/long, %s found",
arg->ob_type->tp_name);
Py_Type(arg)->tp_name);
return PyLong_FromUnsignedLong(htonl((unsigned long)x));
}
@ -4274,7 +4273,7 @@ init_socket(void)
if (!os_init())
return;
sock_type.ob_type = &PyType_Type;
Py_Type(&sock_type) = &PyType_Type;
m = Py_InitModule3(PySocket_MODULE_NAME,
socket_methods,
socket_doc);

View File

@ -42,8 +42,8 @@ static sadstatusobject *sads_alloc(void); /* Forward */
static PyObject *SunAudioError;
#define is_sadobject(v) ((v)->ob_type == &Sadtype)
#define is_sadstatusobject(v) ((v)->ob_type == &Sadstatustype)
#define is_sadobject(v) (Py_Type(v) == &Sadtype)
#define is_sadstatusobject(v) (Py_Type(v) == &Sadstatustype)
static sadobject *
@ -409,8 +409,7 @@ sads_setattr(sadstatusobject *xp, char *name, PyObject *v)
static PyTypeObject Sadtype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"sunaudiodev.sun_audio_device", /*tp_name*/
sizeof(sadobject), /*tp_size*/
0, /*tp_itemsize*/
@ -424,8 +423,7 @@ static PyTypeObject Sadtype = {
};
static PyTypeObject Sadstatustype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"sunaudiodev.sun_audio_device_status", /*tp_name*/
sizeof(sadstatusobject), /*tp_size*/
0, /*tp_itemsize*/

View File

@ -126,8 +126,7 @@ lock_getattr(lockobject *self, char *name)
}
static PyTypeObject Locktype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"thread.lock", /*tp_name*/
sizeof(lockobject), /*tp_size*/
0, /*tp_itemsize*/
@ -251,7 +250,7 @@ local_dealloc(localobject *self)
}
local_clear(self);
self->ob_type->tp_free((PyObject*)self);
Py_Type(self)->tp_free((PyObject*)self);
}
static PyObject *
@ -283,8 +282,8 @@ _ldict(localobject *self)
Py_INCREF(ldict);
self->dict = ldict; /* still borrowed */
if (self->ob_type->tp_init != PyBaseObject_Type.tp_init &&
self->ob_type->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
@ -336,8 +335,7 @@ static PyGetSetDef local_getset[] = {
static PyObject *local_getattro(localobject *, PyObject *);
static PyTypeObject localtype = {
PyObject_HEAD_INIT(NULL)
/* ob_size */ 0,
PyVarObject_HEAD_INIT(NULL, 0)
/* tp_name */ "thread._local",
/* tp_basicsize */ sizeof(localobject),
/* tp_itemsize */ 0,
@ -388,7 +386,7 @@ local_getattro(localobject *self, PyObject *name)
if (ldict == NULL)
return NULL;
if (self->ob_type != &localtype)
if (Py_Type(self) != &localtype)
/* use generic lookup for subtypes */
return PyObject_GenericGetAttr((PyObject *)self, name);

View File

@ -1134,8 +1134,7 @@ static PyMethodDef unicodedata_functions[] = {
static PyTypeObject UCD_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"unicodedata.UCD", /*tp_name*/
sizeof(PreviousDBVersion), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -1193,7 +1192,7 @@ initunicodedata(void)
{
PyObject *m, *v;
UCD_Type.ob_type = &PyType_Type;
Py_Type(&UCD_Type) = &PyType_Type;
m = Py_InitModule3(
"unicodedata", unicodedata_functions, unicodedata_docstring);

View File

@ -25,7 +25,7 @@ typedef struct {
static PyTypeObject Xxo_Type;
#define XxoObject_Check(v) ((v)->ob_type == &Xxo_Type)
#define XxoObject_Check(v) (Py_Type(v) == &Xxo_Type)
static XxoObject *
newXxoObject(PyObject *arg)
@ -97,8 +97,7 @@ Xxo_setattr(XxoObject *self, char *name, PyObject *v)
static PyTypeObject Xxo_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"xxmodule.Xxo", /*tp_name*/
sizeof(XxoObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@ -216,8 +215,7 @@ xx_roj(PyObject *self, PyObject *args)
static PyTypeObject Str_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"xxmodule.Str", /*tp_name*/
0, /*tp_basicsize*/
0, /*tp_itemsize*/
@ -272,8 +270,7 @@ null_richcompare(PyObject *self, PyObject *other, int op)
static PyTypeObject Null_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
PyVarObject_HEAD_INIT(NULL, 0)
"xxmodule.Null", /*tp_name*/
0, /*tp_basicsize*/
0, /*tp_itemsize*/

View File

@ -101,8 +101,7 @@ static PyGetSetDef spamlist_getsets[] = {
};
static PyTypeObject spamlist_type = {
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
0,
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
"xxsubtype.spamlist",
sizeof(spamlistobject),
0,
@ -193,8 +192,7 @@ static PyMemberDef spamdict_members[] = {
};
static PyTypeObject spamdict_type = {
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
0,
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
"xxsubtype.spamdict",
sizeof(spamdictobject),
0,

View File

@ -181,7 +181,7 @@ zipimporter_dealloc(ZipImporter *self)
Py_XDECREF(self->archive);
Py_XDECREF(self->prefix);
Py_XDECREF(self->files);
self->ob_type->tp_free((PyObject *)self);
Py_Type(self)->tp_free((PyObject *)self);
}
static PyObject *
@ -561,8 +561,7 @@ a valid Zip archive.");
#define DEFERRED_ADDRESS(ADDR) 0
static PyTypeObject ZipImporter_Type = {
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
0,
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
"zipimport.zipimporter",
sizeof(ZipImporter),
0, /* tp_itemsize */

View File

@ -935,8 +935,7 @@ static PyMethodDef zlib_methods[] =
};
static PyTypeObject Comptype = {
PyObject_HEAD_INIT(0)
0,
PyVarObject_HEAD_INIT(0, 0)
"zlib.Compress",
sizeof(compobject),
0,
@ -952,8 +951,7 @@ static PyTypeObject Comptype = {
};
static PyTypeObject Decomptype = {
PyObject_HEAD_INIT(0)
0,
PyVarObject_HEAD_INIT(0, 0)
"zlib.Decompress",
sizeof(compobject),
0,
@ -987,8 +985,8 @@ PyMODINIT_FUNC
PyInit_zlib(void)
{
PyObject *m, *ver;
Comptype.ob_type = &PyType_Type;
Decomptype.ob_type = &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);

View File

@ -146,8 +146,7 @@ static PyNumberMethods bool_as_number = {
/* The type object for bool. Note that this cannot be subclassed! */
PyTypeObject PyBool_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"bool",
sizeof(PyIntObject),
0,

View File

@ -664,8 +664,7 @@ static PyBufferProcs buffer_as_buffer = {
};
PyTypeObject PyBuffer_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"buffer",
sizeof(PyBufferObject),
0,

View File

@ -99,8 +99,7 @@ static PyGetSetDef cell_getsetlist[] = {
};
PyTypeObject PyCell_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"cell",
sizeof(PyCellObject),
0,

View File

@ -135,8 +135,7 @@ extension modules, so that extension modules can use the Python import\n\
mechanism to link to one another.");
PyTypeObject PyCObject_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /*ob_size*/
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"PyCObject", /*tp_name*/
sizeof(PyCObject), /*tp_basicsize*/
0, /*tp_itemsize*/

View File

@ -354,8 +354,7 @@ code_hash(PyCodeObject *co)
/* XXX code objects need to participate in GC? */
PyTypeObject PyCode_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"code",
sizeof(PyCodeObject),
0,

View File

@ -1074,8 +1074,7 @@ static PyNumberMethods complex_as_number = {
};
PyTypeObject PyComplex_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"complex",
sizeof(PyComplexObject),
0,

View File

@ -382,8 +382,7 @@ descr_traverse(PyObject *self, visitproc visit, void *arg)
}
static PyTypeObject PyMethodDescr_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"method_descriptor",
sizeof(PyMethodDescrObject),
0,
@ -421,8 +420,7 @@ static PyTypeObject PyMethodDescr_Type = {
/* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */
static PyTypeObject PyClassMethodDescr_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"classmethod_descriptor",
sizeof(PyMethodDescrObject),
0,
@ -459,8 +457,7 @@ static PyTypeObject PyClassMethodDescr_Type = {
};
static PyTypeObject PyMemberDescr_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"member_descriptor",
sizeof(PyMemberDescrObject),
0,
@ -497,8 +494,7 @@ static PyTypeObject PyMemberDescr_Type = {
};
static PyTypeObject PyGetSetDescr_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"getset_descriptor",
sizeof(PyGetSetDescrObject),
0,
@ -535,8 +531,7 @@ static PyTypeObject PyGetSetDescr_Type = {
};
PyTypeObject PyWrapperDescr_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"wrapper_descriptor",
sizeof(PyWrapperDescrObject),
0,
@ -825,8 +820,7 @@ proxy_richcompare(proxyobject *v, PyObject *w, int op)
}
static PyTypeObject proxytype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictproxy", /* tp_name */
sizeof(proxyobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1007,8 +1001,7 @@ wrapper_traverse(PyObject *self, visitproc visit, void *arg)
}
static PyTypeObject wrappertype = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"method-wrapper", /* tp_name */
sizeof(wrapperobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -1238,8 +1231,7 @@ property_traverse(PyObject *self, visitproc visit, void *arg)
}
PyTypeObject PyProperty_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"property", /* tp_name */
sizeof(propertyobject), /* tp_basicsize */
0, /* tp_itemsize */

View File

@ -204,7 +204,7 @@ PyDict_New(void)
if (num_free_dicts) {
mp = free_dicts[--num_free_dicts];
assert (mp != NULL);
assert (mp->ob_type == &PyDict_Type);
assert (Py_Type(mp) == &PyDict_Type);
_Py_NewReference((PyObject *)mp);
if (mp->ma_fill) {
EMPTY_TO_MINSIZE(mp);
@ -849,10 +849,10 @@ dict_dealloc(register dictobject *mp)
}
if (mp->ma_table != mp->ma_smalltable)
PyMem_DEL(mp->ma_table);
if (num_free_dicts < MAXFREEDICTS && mp->ob_type == &PyDict_Type)
if (num_free_dicts < MAXFREEDICTS && Py_Type(mp) == &PyDict_Type)
free_dicts[num_free_dicts++] = mp;
else
mp->ob_type->tp_free((PyObject *)mp);
Py_Type(mp)->tp_free((PyObject *)mp);
Py_TRASHCAN_SAFE_END(mp)
}
@ -1011,7 +1011,7 @@ dict_subscript(dictobject *mp, register PyObject *key)
if (missing_str == NULL)
missing_str =
PyString_InternFromString("__missing__");
missing = _PyType_Lookup(mp->ob_type, missing_str);
missing = _PyType_Lookup(Py_Type(mp), missing_str);
if (missing != NULL)
return PyObject_CallFunctionObjArgs(missing,
(PyObject *)mp, key, NULL);
@ -2119,8 +2119,7 @@ PyDoc_STRVAR(dictionary_doc,
" in the keyword argument list. For example: dict(one=1, two=2)");
PyTypeObject PyDict_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dict",
sizeof(dictobject),
0,
@ -2302,8 +2301,7 @@ fail:
}
PyTypeObject PyDictIterKey_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictionary-keyiterator", /* tp_name */
sizeof(dictiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2375,8 +2373,7 @@ fail:
}
PyTypeObject PyDictIterValue_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictionary-valueiterator", /* tp_name */
sizeof(dictiterobject), /* tp_basicsize */
0, /* tp_itemsize */
@ -2462,8 +2459,7 @@ fail:
}
PyTypeObject PyDictIterItem_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"dictionary-itemiterator", /* tp_name */
sizeof(dictiterobject), /* tp_basicsize */
0, /* tp_itemsize */

Some files were not shown because too many files have changed in this diff Show More