#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
This commit is contained in:
parent
d586559c31
commit
e93237dfcc
|
@ -1051,7 +1051,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
|
|||
*/
|
||||
|
||||
#define PySequence_ITEM(o, i)\
|
||||
( Py_Type(o)->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
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef PyIntObject PyBoolObject;
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||
|
||||
#define PyBool_Check(x) (Py_Type(x) == &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!!! */
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
|
||||
|
||||
#define PyBuffer_Check(op) (Py_Type(op) == &PyBuffer_Type)
|
||||
#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type)
|
||||
|
||||
#define Py_END_OF_BUFFER (-1)
|
||||
|
||||
|
|
|
@ -60,9 +60,9 @@ static struct PycStringIO_CAPI {
|
|||
|
||||
/* These can be used to test if you have one */
|
||||
#define PycStringIO_InputCheck(O) \
|
||||
(Py_Type(O)==PycStringIO->InputType)
|
||||
(Py_TYPE(O)==PycStringIO->InputType)
|
||||
#define PycStringIO_OutputCheck(O) \
|
||||
(Py_Type(O)==PycStringIO->OutputType)
|
||||
(Py_TYPE(O)==PycStringIO->OutputType)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCell_Type;
|
||||
|
||||
#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type)
|
||||
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||
|
|
|
@ -16,7 +16,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCObject_Type;
|
||||
|
||||
#define PyCObject_Check(op) (Py_Type(op) == &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
|
||||
|
|
|
@ -60,7 +60,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCode_Type;
|
||||
|
||||
#define PyCode_Check(op) (Py_Type(op) == &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) \
|
||||
((*Py_Type((co)->co_code)->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 {
|
||||
|
|
|
@ -43,7 +43,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
||||
|
||||
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) (Py_Type(op) == &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);
|
||||
|
|
|
@ -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) (Py_Type(op) == &PyDateTime_DateType)
|
||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_Type(op) == &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) (Py_Type(op) == PyDateTimeAPI->DateType)
|
||||
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_Type(op) == 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) \
|
||||
|
|
|
@ -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) (Py_Type(d)->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 *);
|
||||
|
|
|
@ -91,8 +91,8 @@ struct _dictobject {
|
|||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) (Py_Type(op) == &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);
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyFile_Type;
|
||||
|
||||
#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type)
|
||||
#define PyFile_CheckExact(op) (Py_Type(op) == &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);
|
||||
|
|
|
@ -19,7 +19,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||
|
||||
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
|
||||
|
||||
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
||||
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyFunction_Type;
|
||||
|
||||
#define PyFunction_Check(op) (Py_Type(op) == &PyFunction_Type)
|
||||
#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
||||
|
||||
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) (Py_Type(op) == &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
|
||||
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
|
||||
|
|
|
@ -7,13 +7,13 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
|
||||
|
||||
#define PySeqIter_Check(op) (Py_Type(op) == &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) (Py_Type(op) == &PyCallIter_Type)
|
||||
#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -41,8 +41,8 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyList_Type;
|
||||
|
||||
#define PyList_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LIST_SUBCLASS)
|
||||
#define PyList_CheckExact(op) (Py_Type(op) == &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) Py_Size(op)
|
||||
#define PyList_GET_SIZE(op) Py_SIZE(op)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
|
|||
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||
|
||||
#define PyLong_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||
#define PyLong_CheckExact(op) (Py_Type(op) == &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);
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
|
||||
|
||||
#define PyCFunction_Check(op) (Py_Type(op) == &PyCFunction_Type)
|
||||
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
|
||||
|
||||
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
|
||||
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
|
||||
|
|
|
@ -10,7 +10,7 @@ extern "C" {
|
|||
PyAPI_DATA(PyTypeObject) PyModule_Type;
|
||||
|
||||
#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) (Py_Type(op) == &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyModule_New(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
|
||||
|
|
|
@ -111,9 +111,14 @@ 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)
|
||||
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
|
||||
|
||||
/* B/w compatibility */
|
||||
#define Py_Refcnt(ob) Py_REFCNT(op)
|
||||
#define Py_Type(op) Py_TYPE(op)
|
||||
#define Py_Size(op) Py_SIZE(op)
|
||||
|
||||
/*
|
||||
Type objects contain a string containing the type name (to help somewhat
|
||||
|
@ -370,21 +375,21 @@ typedef struct _heaptypeobject {
|
|||
|
||||
/* access macro to the members which are floating "behind" the object */
|
||||
#define PyHeapType_GET_MEMBERS(etype) \
|
||||
((PyMemberDef *)(((char *)etype) + Py_Type(etype)->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) \
|
||||
(Py_Type(ob) == (tp) || PyType_IsSubtype(Py_Type(ob), (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(Py_Type(op), Py_TPFLAGS_TYPE_SUBCLASS)
|
||||
#define PyType_CheckExact(op) (Py_Type(op) == &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);
|
||||
|
@ -619,9 +624,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(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_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)
|
||||
|
@ -646,13 +651,13 @@ 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 \
|
||||
Py_Refcnt(op) = 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 \
|
||||
(*Py_Type(op)->tp_dealloc)((PyObject *)(op)))
|
||||
(*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
|
||||
#endif /* !Py_TRACE_REFS */
|
||||
|
||||
#define Py_INCREF(op) ( \
|
||||
|
|
|
@ -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) \
|
||||
( Py_Type(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
#define PyObject_INIT_VAR(op, typeobj, size) \
|
||||
( Py_Size(op) = (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(Py_Type(o)) && \
|
||||
(Py_Type(o)->tp_is_gc == NULL || Py_Type(o)->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)) + Py_Type(o)->tp_weaklistoffset))
|
||||
((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ typedef struct {
|
|||
WINDOW *win;
|
||||
} PyCursesWindowObject;
|
||||
|
||||
#define PyCursesWindow_Check(v) (Py_Type(v) == &PyCursesWindow_Type)
|
||||
#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type)
|
||||
|
||||
#ifdef CURSES_MODULE
|
||||
/* This section is used when compiling _cursesmodule.c */
|
||||
|
|
|
@ -20,7 +20,7 @@ they are represented by a start, stop, and step datamembers.
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyRange_Type;
|
||||
|
||||
#define PyRange_Check(op) (Py_Type(op) == &PyRange_Type)
|
||||
#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -66,13 +66,13 @@ PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
|
|||
* hash is -1
|
||||
*/
|
||||
|
||||
#define PyFrozenSet_CheckExact(ob) (Py_Type(ob) == &PyFrozenSet_Type)
|
||||
#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_CheckExact(ob) \
|
||||
(Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type)
|
||||
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_Check(ob) \
|
||||
(Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type || \
|
||||
PyType_IsSubtype(Py_Type(ob), &PySet_Type) || \
|
||||
PyType_IsSubtype(Py_Type(ob), &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 *);
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySlice_Type;
|
||||
|
||||
#define PySlice_Check(op) (Py_Type(op) == &PySlice_Type)
|
||||
#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
|
||||
PyObject* step);
|
||||
|
|
|
@ -56,8 +56,8 @@ PyAPI_DATA(PyTypeObject) PyBaseString_Type;
|
|||
PyAPI_DATA(PyTypeObject) PyString_Type;
|
||||
|
||||
#define PyString_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_STRING_SUBCLASS)
|
||||
#define PyString_CheckExact(op) (Py_Type(op) == &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) Py_Size(op)
|
||||
#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. */
|
||||
|
|
|
@ -49,7 +49,7 @@ typedef struct _symtable_entry {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySTEntry_Type;
|
||||
|
||||
#define PySTEntry_Check(op) (Py_Type(op) == &PySTEntry_Type)
|
||||
#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
|
||||
|
||||
|
|
|
@ -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) (Py_Type(v) == &PyTraceBack_Type)
|
||||
#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyTuple_Type;
|
||||
|
||||
#define PyTuple_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TUPLE_SUBCLASS)
|
||||
#define PyTuple_CheckExact(op) (Py_Type(op) == &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) Py_Size(op)
|
||||
#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)
|
||||
|
|
|
@ -401,8 +401,8 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyUnicode_Type;
|
||||
|
||||
#define PyUnicode_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_UNICODE_SUBCLASS)
|
||||
#define PyUnicode_CheckExact(op) (Py_Type(op) == &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) \
|
||||
|
|
|
@ -44,10 +44,10 @@ PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
|||
|
||||
#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckRefExact(op) \
|
||||
(Py_Type(op) == &_PyWeakref_RefType)
|
||||
(Py_TYPE(op) == &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckProxy(op) \
|
||||
((Py_Type(op) == &_PyWeakref_ProxyType) || \
|
||||
(Py_Type(op) == &_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
|
||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
|
|||
Core and builtins
|
||||
-----------------
|
||||
|
||||
- Issue #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE
|
||||
and Py_REFCNT.
|
||||
|
||||
- Issue #1635: Platform independent creation and representation of NaN
|
||||
and INF. float("nan"), float("inf") and float("-inf") now work on every
|
||||
platform with IEEE 754 semantics.
|
||||
|
|
|
@ -205,16 +205,16 @@ staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLoc
|
|||
|
||||
#ifndef Py_Type
|
||||
/* for compatibility with Python 2.5 and earlier */
|
||||
#define Py_Type(ob) (((PyObject*)(ob))->ob_type)
|
||||
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
||||
#endif
|
||||
|
||||
#define DBObject_Check(v) (Py_Type(v) == &DB_Type)
|
||||
#define DBCursorObject_Check(v) (Py_Type(v) == &DBCursor_Type)
|
||||
#define DBEnvObject_Check(v) (Py_Type(v) == &DBEnv_Type)
|
||||
#define DBTxnObject_Check(v) (Py_Type(v) == &DBTxn_Type)
|
||||
#define DBLockObject_Check(v) (Py_Type(v) == &DBLock_Type)
|
||||
#define DBObject_Check(v) (Py_TYPE(v) == &DB_Type)
|
||||
#define DBCursorObject_Check(v) (Py_TYPE(v) == &DBCursor_Type)
|
||||
#define DBEnvObject_Check(v) (Py_TYPE(v) == &DBEnv_Type)
|
||||
#define DBTxnObject_Check(v) (Py_TYPE(v) == &DBTxn_Type)
|
||||
#define DBLockObject_Check(v) (Py_TYPE(v) == &DBLock_Type)
|
||||
#if (DBVER >= 43)
|
||||
#define DBSequenceObject_Check(v) (Py_Type(v) == &DBSequence_Type)
|
||||
#define DBSequenceObject_Check(v) (Py_TYPE(v) == &DBSequence_Type)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -383,7 +383,7 @@ make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags)
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"String or Integer object expected for key, %s found",
|
||||
Py_Type(keyobj)->tp_name);
|
||||
Py_TYPE(keyobj)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ static int makeDBError(int err)
|
|||
static void makeTypeError(char* expected, PyObject* found)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.",
|
||||
expected, Py_Type(found)->tp_name);
|
||||
expected, Py_TYPE(found)->tp_name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5535,13 +5535,13 @@ DL_EXPORT(void) init_bsddb(void)
|
|||
|
||||
/* Initialize the type of the new type objects here; doing it here
|
||||
is required for portability to Windows without requiring C++. */
|
||||
Py_Type(&DB_Type) = &PyType_Type;
|
||||
Py_Type(&DBCursor_Type) = &PyType_Type;
|
||||
Py_Type(&DBEnv_Type) = &PyType_Type;
|
||||
Py_Type(&DBTxn_Type) = &PyType_Type;
|
||||
Py_Type(&DBLock_Type) = &PyType_Type;
|
||||
Py_TYPE(&DB_Type) = &PyType_Type;
|
||||
Py_TYPE(&DBCursor_Type) = &PyType_Type;
|
||||
Py_TYPE(&DBEnv_Type) = &PyType_Type;
|
||||
Py_TYPE(&DBTxn_Type) = &PyType_Type;
|
||||
Py_TYPE(&DBLock_Type) = &PyType_Type;
|
||||
#if (DBVER >= 43)
|
||||
Py_Type(&DBSequence_Type) = &PyType_Type;
|
||||
Py_TYPE(&DBSequence_Type) = &PyType_Type;
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -583,7 +583,7 @@ deque_dealloc(dequeobject *deque)
|
|||
}
|
||||
deque->leftblock = NULL;
|
||||
deque->rightblock = NULL;
|
||||
Py_Type(deque)->tp_free(deque);
|
||||
Py_TYPE(deque)->tp_free(deque);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -619,9 +619,9 @@ static PyObject *
|
|||
deque_copy(PyObject *deque)
|
||||
{
|
||||
if (((dequeobject *)deque)->maxlen == -1)
|
||||
return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "O", deque, NULL);
|
||||
return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL);
|
||||
else
|
||||
return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "Oi",
|
||||
return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi",
|
||||
deque, ((dequeobject *)deque)->maxlen, NULL);
|
||||
}
|
||||
|
||||
|
@ -642,14 +642,14 @@ deque_reduce(dequeobject *deque)
|
|||
}
|
||||
if (dict == NULL) {
|
||||
if (deque->maxlen == -1)
|
||||
result = Py_BuildValue("O(O)", Py_Type(deque), aslist);
|
||||
result = Py_BuildValue("O(O)", Py_TYPE(deque), aslist);
|
||||
else
|
||||
result = Py_BuildValue("O(Oi)", Py_Type(deque), aslist, deque->maxlen);
|
||||
result = Py_BuildValue("O(Oi)", Py_TYPE(deque), aslist, deque->maxlen);
|
||||
} else {
|
||||
if (deque->maxlen == -1)
|
||||
result = Py_BuildValue("O(OO)O", Py_Type(deque), aslist, Py_None, dict);
|
||||
result = Py_BuildValue("O(OO)O", Py_TYPE(deque), aslist, Py_None, dict);
|
||||
else
|
||||
result = Py_BuildValue("O(Oi)O", Py_Type(deque), aslist, deque->maxlen, dict);
|
||||
result = Py_BuildValue("O(Oi)O", Py_TYPE(deque), aslist, deque->maxlen, dict);
|
||||
}
|
||||
Py_XDECREF(dict);
|
||||
Py_DECREF(aslist);
|
||||
|
@ -980,7 +980,7 @@ static void
|
|||
dequeiter_dealloc(dequeiterobject *dio)
|
||||
{
|
||||
Py_XDECREF(dio->deque);
|
||||
Py_Type(dio)->tp_free(dio);
|
||||
Py_TYPE(dio)->tp_free(dio);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1188,7 +1188,7 @@ defdict_copy(defdictobject *dd)
|
|||
whose class constructor has the same signature. Subclasses that
|
||||
define a different constructor signature must override copy().
|
||||
*/
|
||||
return PyObject_CallFunctionObjArgs((PyObject*)Py_Type(dd),
|
||||
return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd),
|
||||
dd->default_factory, dd, NULL);
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ defdict_reduce(defdictobject *dd)
|
|||
Py_DECREF(args);
|
||||
return NULL;
|
||||
}
|
||||
result = PyTuple_Pack(5, Py_Type(dd), args,
|
||||
result = PyTuple_Pack(5, Py_TYPE(dd), args,
|
||||
Py_None, Py_None, items);
|
||||
Py_DECREF(items);
|
||||
Py_DECREF(args);
|
||||
|
|
|
@ -125,7 +125,7 @@ typedef struct {
|
|||
|
||||
staticforward PyTypeObject Reader_Type;
|
||||
|
||||
#define ReaderObject_Check(v) (Py_Type(v) == &Reader_Type)
|
||||
#define ReaderObject_Check(v) (Py_TYPE(v) == &Reader_Type)
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
|
@ -310,7 +310,7 @@ static void
|
|||
Dialect_dealloc(DialectObj *self)
|
||||
{
|
||||
Py_XDECREF(self->lineterminator);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static char *dialect_kws[] = {
|
||||
|
|
|
@ -333,7 +333,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
|
|||
Py_INCREF(value);
|
||||
return value;
|
||||
}
|
||||
ob_name = (ob) ? Py_Type(ob)->tp_name : "???";
|
||||
ob_name = (ob) ? Py_TYPE(ob)->tp_name : "???";
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instance instead of pointer to %s",
|
||||
((PyTypeObject *)type)->tp_name, ob_name);
|
||||
|
@ -349,7 +349,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instance instead of %s",
|
||||
((PyTypeObject *)type)->tp_name,
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
|
|||
char *ptr;
|
||||
Py_ssize_t size;
|
||||
if (PyBuffer_Check(value)) {
|
||||
size = Py_Type(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
|
||||
size = Py_TYPE(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
|
||||
if (size < 0)
|
||||
return -1;
|
||||
} else if (-1 == PyString_AsStringAndSize(value, &ptr, &size)) {
|
||||
|
@ -803,7 +803,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
|
|||
} else if (!PyString_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"string expected instead of %s instance",
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
} else
|
||||
Py_INCREF(value);
|
||||
|
@ -863,7 +863,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
|
|||
} else if (!PyUnicode_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unicode string expected instead of %s instance",
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
} else
|
||||
Py_INCREF(value);
|
||||
|
@ -2081,7 +2081,7 @@ static void
|
|||
CData_dealloc(PyObject *self)
|
||||
{
|
||||
CData_clear((CDataObject *)self);
|
||||
Py_Type(self)->tp_free(self);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyMemberDef CData_members[] = {
|
||||
|
@ -2354,7 +2354,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instance, got %s",
|
||||
((PyTypeObject *)type)->tp_name,
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2385,7 +2385,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
|||
if (p1->proto != p2->proto) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"incompatible types, %s instance instead of %s instance",
|
||||
Py_Type(value)->tp_name,
|
||||
Py_TYPE(value)->tp_name,
|
||||
((PyTypeObject *)type)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2404,7 +2404,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
|||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"incompatible types, %s instance instead of %s instance",
|
||||
Py_Type(value)->tp_name,
|
||||
Py_TYPE(value)->tp_name,
|
||||
((PyTypeObject *)type)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2665,7 +2665,7 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index)
|
|||
Py_SAFE_DOWNCAST(index, Py_ssize_t, int),
|
||||
PyType_Check(arg) ?
|
||||
((PyTypeObject *)arg)->tp_name :
|
||||
Py_Type(arg)->tp_name);
|
||||
Py_TYPE(arg)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3451,7 +3451,7 @@ static void
|
|||
CFuncPtr_dealloc(CFuncPtrObject *self)
|
||||
{
|
||||
CFuncPtr_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -3461,11 +3461,11 @@ CFuncPtr_repr(CFuncPtrObject *self)
|
|||
if (self->index)
|
||||
return PyString_FromFormat("<COM method offset %d: %s at %p>",
|
||||
self->index - 0x1000,
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
self);
|
||||
#endif
|
||||
return PyString_FromFormat("<%s object at %p>",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
self);
|
||||
}
|
||||
|
||||
|
@ -4195,7 +4195,7 @@ static PyGetSetDef Simple_getsets[] = {
|
|||
static PyObject *
|
||||
Simple_from_outparm(PyObject *self, PyObject *args)
|
||||
{
|
||||
if (IsSimpleSubType((PyObject *)Py_Type(self))) {
|
||||
if (IsSimpleSubType((PyObject *)Py_TYPE(self))) {
|
||||
Py_INCREF(self);
|
||||
return self;
|
||||
}
|
||||
|
@ -4260,9 +4260,9 @@ Simple_repr(CDataObject *self)
|
|||
PyObject *val, *name, *args, *result;
|
||||
static PyObject *format;
|
||||
|
||||
if (Py_Type(self)->tp_base != &Simple_Type) {
|
||||
if (Py_TYPE(self)->tp_base != &Simple_Type) {
|
||||
return PyString_FromFormat("<%s object at %p>",
|
||||
Py_Type(self)->tp_name, self);
|
||||
Py_TYPE(self)->tp_name, self);
|
||||
}
|
||||
|
||||
if (format == NULL) {
|
||||
|
@ -4275,7 +4275,7 @@ Simple_repr(CDataObject *self)
|
|||
if (val == NULL)
|
||||
return NULL;
|
||||
|
||||
name = PyString_FromString(Py_Type(self)->tp_name);
|
||||
name = PyString_FromString(Py_TYPE(self)->tp_name);
|
||||
if (name == NULL) {
|
||||
Py_DECREF(val);
|
||||
return NULL;
|
||||
|
@ -4446,7 +4446,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instead of %s",
|
||||
((PyTypeObject *)(stgdict->proto))->tp_name,
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -4876,7 +4876,7 @@ cast_check_pointertype(PyObject *arg)
|
|||
"cast() argument 2 must be a pointer type, not %s",
|
||||
PyType_Check(arg)
|
||||
? ((PyTypeObject *)arg)->tp_name
|
||||
: Py_Type(arg)->tp_name);
|
||||
: Py_TYPE(arg)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5003,37 +5003,37 @@ init_ctypes(void)
|
|||
if (PyType_Ready(&CData_Type) < 0)
|
||||
return;
|
||||
|
||||
Py_Type(&Struct_Type) = &StructType_Type;
|
||||
Py_TYPE(&Struct_Type) = &StructType_Type;
|
||||
Struct_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Struct_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type);
|
||||
|
||||
Py_Type(&Union_Type) = &UnionType_Type;
|
||||
Py_TYPE(&Union_Type) = &UnionType_Type;
|
||||
Union_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Union_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "Union", (PyObject *)&Union_Type);
|
||||
|
||||
Py_Type(&Pointer_Type) = &PointerType_Type;
|
||||
Py_TYPE(&Pointer_Type) = &PointerType_Type;
|
||||
Pointer_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Pointer_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "_Pointer", (PyObject *)&Pointer_Type);
|
||||
|
||||
Py_Type(&Array_Type) = &ArrayType_Type;
|
||||
Py_TYPE(&Array_Type) = &ArrayType_Type;
|
||||
Array_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Array_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "Array", (PyObject *)&Array_Type);
|
||||
|
||||
Py_Type(&Simple_Type) = &SimpleType_Type;
|
||||
Py_TYPE(&Simple_Type) = &SimpleType_Type;
|
||||
Simple_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Simple_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type);
|
||||
|
||||
Py_Type(&CFuncPtr_Type) = &CFuncPtrType_Type;
|
||||
Py_TYPE(&CFuncPtr_Type) = &CFuncPtrType_Type;
|
||||
CFuncPtr_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&CFuncPtr_Type) < 0)
|
||||
return;
|
||||
|
|
|
@ -1180,7 +1180,7 @@ call_commethod(PyObject *self, PyObject *args)
|
|||
if (!CDataObject_Check(pcom) || (pcom->b_size != sizeof(void *))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"COM Pointer expected instead of %s instance",
|
||||
Py_Type(pcom)->tp_name);
|
||||
Py_TYPE(pcom)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1420,7 +1420,7 @@ byref(PyObject *self, PyObject *obj)
|
|||
if (!CDataObject_Check(obj)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"byref() argument must be a ctypes instance, not '%s'",
|
||||
Py_Type(obj)->tp_name);
|
||||
Py_TYPE(obj)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
|
|||
Py_DECREF(fieldlist);
|
||||
return -1;
|
||||
}
|
||||
if (Py_Type(fdescr) != &CField_Type) {
|
||||
if (Py_TYPE(fdescr) != &CField_Type) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
Py_DECREF(fdescr);
|
||||
Py_DECREF(fieldlist);
|
||||
|
@ -214,7 +214,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
|
|||
Py_DECREF(fieldlist);
|
||||
return -1;
|
||||
}
|
||||
assert(Py_Type(new_descr) == &CField_Type);
|
||||
assert(Py_TYPE(new_descr) == &CField_Type);
|
||||
new_descr->size = fdescr->size;
|
||||
new_descr->offset = fdescr->offset + offset;
|
||||
new_descr->index = fdescr->index + index;
|
||||
|
@ -262,7 +262,7 @@ MakeAnonFields(PyObject *type)
|
|||
Py_DECREF(anon_names);
|
||||
return -1;
|
||||
}
|
||||
assert(Py_Type(descr) == &CField_Type);
|
||||
assert(Py_TYPE(descr) == &CField_Type);
|
||||
descr->anonymous = 1;
|
||||
|
||||
/* descr is in the field descriptor. */
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct {
|
|||
|
||||
PyTypeObject PyCursesPanel_Type;
|
||||
|
||||
#define PyCursesPanel_Check(v) (Py_Type(v) == &PyCursesPanel_Type)
|
||||
#define PyCursesPanel_Check(v) (Py_TYPE(v) == &PyCursesPanel_Type)
|
||||
|
||||
/* Some helper functions. The problem is that there's always a window
|
||||
associated with a panel. To ensure that Python's GC doesn't pull
|
||||
|
@ -457,7 +457,7 @@ init_curses_panel(void)
|
|||
PyObject *m, *d, *v;
|
||||
|
||||
/* Initialize object type */
|
||||
Py_Type(&PyCursesPanel_Type) = &PyType_Type;
|
||||
Py_TYPE(&PyCursesPanel_Type) = &PyType_Type;
|
||||
|
||||
import_curses();
|
||||
|
||||
|
|
|
@ -2656,7 +2656,7 @@ init_curses(void)
|
|||
static void *PyCurses_API[PyCurses_API_pointers];
|
||||
|
||||
/* Initialize object type */
|
||||
Py_Type(&PyCursesWindow_Type) = &PyType_Type;
|
||||
Py_TYPE(&PyCursesWindow_Type) = &PyType_Type;
|
||||
|
||||
/* Initialize the C API pointer array */
|
||||
PyCurses_API[0] = (void *)&PyCursesWindow_Type;
|
||||
|
|
|
@ -269,7 +269,7 @@ typedef struct {
|
|||
|
||||
staticforward PyTypeObject Element_Type;
|
||||
|
||||
#define Element_CheckExact(op) (Py_Type(op) == &Element_Type)
|
||||
#define Element_CheckExact(op) (Py_TYPE(op) == &Element_Type)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* element constructor and destructor */
|
||||
|
@ -1207,7 +1207,7 @@ element_setslice(PyObject* self_, Py_ssize_t start, Py_ssize_t end, PyObject* it
|
|||
/* FIXME: support arbitrary sequences? */
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"expected list, not \"%.200s\"", Py_Type(item)->tp_name
|
||||
"expected list, not \"%.200s\"", Py_TYPE(item)->tp_name
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1440,7 +1440,7 @@ typedef struct {
|
|||
|
||||
staticforward PyTypeObject TreeBuilder_Type;
|
||||
|
||||
#define TreeBuilder_CheckExact(op) (Py_Type(op) == &TreeBuilder_Type)
|
||||
#define TreeBuilder_CheckExact(op) (Py_TYPE(op) == &TreeBuilder_Type)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* constructor and destructor */
|
||||
|
@ -1607,7 +1607,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
|
|||
Py_INCREF(data); self->data = data;
|
||||
} else {
|
||||
/* more than one item; use a list to collect items */
|
||||
if (PyString_CheckExact(self->data) && Py_Refcnt(self->data) == 1 &&
|
||||
if (PyString_CheckExact(self->data) && Py_REFCNT(self->data) == 1 &&
|
||||
PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) {
|
||||
/* expat often generates single character data sections; handle
|
||||
the most common case by resizing the existing string... */
|
||||
|
@ -2623,9 +2623,9 @@ init_elementtree(void)
|
|||
#endif
|
||||
|
||||
/* Patch object type */
|
||||
Py_Type(&Element_Type) = Py_Type(&TreeBuilder_Type) = &PyType_Type;
|
||||
Py_TYPE(&Element_Type) = Py_TYPE(&TreeBuilder_Type) = &PyType_Type;
|
||||
#if defined(USE_EXPAT)
|
||||
Py_Type(&XMLParser_Type) = &PyType_Type;
|
||||
Py_TYPE(&XMLParser_Type) = &PyType_Type;
|
||||
#endif
|
||||
|
||||
m = Py_InitModule("_elementtree", _functions);
|
||||
|
|
|
@ -81,7 +81,7 @@ partial_dealloc(partialobject *pto)
|
|||
Py_XDECREF(pto->args);
|
||||
Py_XDECREF(pto->kw);
|
||||
Py_XDECREF(pto->dict);
|
||||
Py_Type(pto)->tp_free(pto);
|
||||
Py_TYPE(pto)->tp_free(pto);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
@ -463,7 +463,7 @@ init_hashlib(void)
|
|||
* but having some be unsupported. Only init appropriate
|
||||
* constants. */
|
||||
|
||||
Py_Type(&EVPtype) = &PyType_Type;
|
||||
Py_TYPE(&EVPtype) = &PyType_Type;
|
||||
if (PyType_Ready(&EVPtype) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1611,8 +1611,8 @@ init_hotshot(void)
|
|||
{
|
||||
PyObject *module;
|
||||
|
||||
Py_Type(&LogReaderType) = &PyType_Type;
|
||||
Py_Type(&ProfilerType) = &PyType_Type;
|
||||
Py_TYPE(&LogReaderType) = &PyType_Type;
|
||||
Py_TYPE(&ProfilerType) = &PyType_Type;
|
||||
module = Py_InitModule("_hotshot", functions);
|
||||
if (module != NULL) {
|
||||
char *s = get_version_string();
|
||||
|
|
|
@ -120,7 +120,7 @@ typedef struct {
|
|||
staticforward PyTypeObject PyProfiler_Type;
|
||||
|
||||
#define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type)
|
||||
#define PyProfiler_CheckExact(op) (Py_Type(op) == &PyProfiler_Type)
|
||||
#define PyProfiler_CheckExact(op) (Py_TYPE(op) == &PyProfiler_Type)
|
||||
|
||||
/*** External Timers ***/
|
||||
|
||||
|
@ -207,7 +207,7 @@ normalizeUserObj(PyObject *obj)
|
|||
PyObject *self = fn->m_self;
|
||||
PyObject *name = PyString_FromString(fn->m_ml->ml_name);
|
||||
if (name != NULL) {
|
||||
PyObject *mo = _PyType_Lookup(Py_Type(self), name);
|
||||
PyObject *mo = _PyType_Lookup(Py_TYPE(self), name);
|
||||
Py_XINCREF(mo);
|
||||
Py_DECREF(name);
|
||||
if (mo != NULL) {
|
||||
|
@ -756,7 +756,7 @@ profiler_dealloc(ProfilerObject *op)
|
|||
flush_unmatched(op);
|
||||
clearEntries(op);
|
||||
Py_XDECREF(op->externalTimer);
|
||||
Py_Type(op)->tp_free(op);
|
||||
Py_TYPE(op)->tp_free(op);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -84,7 +84,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Random_Type;
|
||||
|
||||
#define RandomObject_Check(v) (Py_Type(v) == &Random_Type)
|
||||
#define RandomObject_Check(v) (Py_TYPE(v) == &Random_Type)
|
||||
|
||||
|
||||
/* Random methods */
|
||||
|
@ -405,7 +405,7 @@ random_jumpahead(RandomObject *self, PyObject *n)
|
|||
if (!PyInt_Check(n) && !PyLong_Check(n)) {
|
||||
PyErr_Format(PyExc_TypeError, "jumpahead requires an "
|
||||
"integer, not '%s'",
|
||||
Py_Type(n)->tp_name);
|
||||
Py_TYPE(n)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void pysqlite_node_dealloc(pysqlite_Node* self)
|
|||
Py_DECREF(self->key);
|
||||
Py_DECREF(self->data);
|
||||
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
|
||||
|
@ -109,7 +109,7 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self)
|
|||
}
|
||||
Py_DECREF(self->mapping);
|
||||
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
|
||||
|
|
|
@ -205,7 +205,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
|
|||
Py_XDECREF(self->collations);
|
||||
Py_XDECREF(self->statements);
|
||||
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
|
||||
|
|
|
@ -134,7 +134,7 @@ void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
|
|||
Py_XDECREF(self->row_factory);
|
||||
Py_XDECREF(self->next_row);
|
||||
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject* _pysqlite_get_converter(PyObject* key)
|
||||
|
|
|
@ -30,7 +30,7 @@ int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* arg
|
|||
|
||||
void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self)
|
||||
{
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyTypeObject pysqlite_PrepareProtocolType= {
|
||||
|
@ -78,6 +78,6 @@ PyTypeObject pysqlite_PrepareProtocolType= {
|
|||
extern int pysqlite_prepare_protocol_setup_types(void)
|
||||
{
|
||||
pysqlite_PrepareProtocolType.tp_new = PyType_GenericNew;
|
||||
Py_Type(&pysqlite_PrepareProtocolType)= &PyType_Type;
|
||||
Py_TYPE(&pysqlite_PrepareProtocolType)= &PyType_Type;
|
||||
return PyType_Ready(&pysqlite_PrepareProtocolType);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ void pysqlite_row_dealloc(pysqlite_Row* self)
|
|||
Py_XDECREF(self->data);
|
||||
Py_XDECREF(self->description);
|
||||
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs)
|
||||
|
|
|
@ -313,7 +313,7 @@ void pysqlite_statement_dealloc(pysqlite_Statement* self)
|
|||
PyObject_ClearWeakRefs((PyObject*)self);
|
||||
}
|
||||
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1689,7 +1689,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
|
|||
#endif
|
||||
|
||||
/* get pointer to string buffer */
|
||||
buffer = Py_Type(string)->tp_as_buffer;
|
||||
buffer = Py_TYPE(string)->tp_as_buffer;
|
||||
if (!buffer || !buffer->bf_getreadbuffer || !buffer->bf_getsegcount ||
|
||||
buffer->bf_getsegcount(string, NULL) != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected string or buffer");
|
||||
|
|
|
@ -127,7 +127,7 @@ static int check_socket_and_wait_for_timeout(PySocketSockObject *s,
|
|||
static PyObject *PySSL_peercert(PySSLObject *self, PyObject *args);
|
||||
static PyObject *PySSL_cipher(PySSLObject *self);
|
||||
|
||||
#define PySSLObject_Check(v) (Py_Type(v) == &PySSL_Type)
|
||||
#define PySSLObject_Check(v) (Py_TYPE(v) == &PySSL_Type)
|
||||
|
||||
typedef enum {
|
||||
SOCKET_IS_NONBLOCKING,
|
||||
|
@ -1365,7 +1365,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg)
|
|||
if (!PyString_Check(arg))
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"RAND_egd() expected string, found %s",
|
||||
Py_Type(arg)->tp_name);
|
||||
Py_TYPE(arg)->tp_name);
|
||||
bytes = RAND_egd(PyString_AS_STRING(arg));
|
||||
if (bytes == -1) {
|
||||
PyErr_SetString(PySSLErrorObject,
|
||||
|
@ -1480,7 +1480,7 @@ init_ssl(void)
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
Py_Type(&PySSL_Type) = &PyType_Type;
|
||||
Py_TYPE(&PySSL_Type) = &PyType_Type;
|
||||
|
||||
m = Py_InitModule3("_ssl", PySSL_methods, module_doc);
|
||||
if (m == NULL)
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
|
||||
|
||||
#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType)
|
||||
#define PyStruct_CheckExact(op) (Py_Type(op) == &PyStructType)
|
||||
#define PyStruct_CheckExact(op) (Py_TYPE(op) == &PyStructType)
|
||||
|
||||
|
||||
/* Exception */
|
||||
|
@ -133,7 +133,7 @@ get_pylong(PyObject *v)
|
|||
Py_INCREF(v);
|
||||
return v;
|
||||
}
|
||||
m = Py_Type(v)->tp_as_number;
|
||||
m = Py_TYPE(v)->tp_as_number;
|
||||
if (m != NULL && m->nb_long != NULL) {
|
||||
v = m->nb_long(v);
|
||||
if (v == NULL)
|
||||
|
@ -1487,7 +1487,7 @@ s_dealloc(PyStructObject *s)
|
|||
PyMem_FREE(s->s_codes);
|
||||
}
|
||||
Py_XDECREF(s->s_format);
|
||||
Py_Type(s)->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1856,7 +1856,7 @@ init_struct(void)
|
|||
if (m == NULL)
|
||||
return;
|
||||
|
||||
Py_Type(&PyStructType) = &PyType_Type;
|
||||
Py_TYPE(&PyStructType) = &PyType_Type;
|
||||
if (PyType_Ready(&PyStructType) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -889,7 +889,7 @@ init_testcapi(void)
|
|||
if (m == NULL)
|
||||
return;
|
||||
|
||||
Py_Type(&test_structmembersType)=&PyType_Type;
|
||||
Py_TYPE(&test_structmembersType)=&PyType_Type;
|
||||
Py_INCREF(&test_structmembersType);
|
||||
PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType);
|
||||
|
||||
|
|
|
@ -262,12 +262,12 @@ typedef struct {
|
|||
Tcl_ObjType *StringType;
|
||||
} TkappObject;
|
||||
|
||||
#define Tkapp_Check(v) (Py_Type(v) == &Tkapp_Type)
|
||||
#define Tkapp_Check(v) (Py_TYPE(v) == &Tkapp_Type)
|
||||
#define Tkapp_Interp(v) (((TkappObject *) (v))->interp)
|
||||
#define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v))
|
||||
|
||||
#define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \
|
||||
(void *) v, Py_Refcnt(v)))
|
||||
(void *) v, Py_REFCNT(v)))
|
||||
|
||||
|
||||
|
||||
|
@ -3105,7 +3105,7 @@ init_tkinter(void)
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
Py_Type(&Tkapp_Type) = &PyType_Type;
|
||||
Py_TYPE(&Tkapp_Type) = &PyType_Type;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
tcl_lock = PyThread_allocate_lock();
|
||||
|
@ -3133,10 +3133,10 @@ init_tkinter(void)
|
|||
|
||||
PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type);
|
||||
|
||||
Py_Type(&Tktt_Type) = &PyType_Type;
|
||||
Py_TYPE(&Tktt_Type) = &PyType_Type;
|
||||
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
|
||||
|
||||
Py_Type(&PyTclObject_Type) = &PyType_Type;
|
||||
Py_TYPE(&PyTclObject_Type) = &PyType_Type;
|
||||
PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type);
|
||||
|
||||
#ifdef TK_AQUA
|
||||
|
|
|
@ -14,7 +14,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *object)
|
|||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) {
|
||||
if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) {
|
||||
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
|
||||
|
||||
result = PyInt_FromSsize_t(_PyWeakref_GetWeakrefCount(*list));
|
||||
|
@ -35,7 +35,7 @@ weakref_getweakrefs(PyObject *self, PyObject *object)
|
|||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) {
|
||||
if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) {
|
||||
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
|
||||
Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct arrayobject {
|
|||
static PyTypeObject Arraytype;
|
||||
|
||||
#define array_Check(op) PyObject_TypeCheck(op, &Arraytype)
|
||||
#define array_CheckExact(op) (Py_Type(op) == &Arraytype)
|
||||
#define array_CheckExact(op) (Py_TYPE(op) == &Arraytype)
|
||||
|
||||
static int
|
||||
array_resize(arrayobject *self, Py_ssize_t newsize)
|
||||
|
@ -53,9 +53,9 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
|||
*/
|
||||
|
||||
if (self->allocated >= newsize &&
|
||||
Py_Size(self) < newsize + 16 &&
|
||||
Py_SIZE(self) < newsize + 16 &&
|
||||
self->ob_item != NULL) {
|
||||
Py_Size(self) = newsize;
|
||||
Py_SIZE(self) = newsize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
|||
* memory critical.
|
||||
*/
|
||||
|
||||
_new_size = (newsize >> 4) + (Py_Size(self) < 8 ? 3 : 7) + newsize;
|
||||
_new_size = (newsize >> 4) + (Py_SIZE(self) < 8 ? 3 : 7) + newsize;
|
||||
items = self->ob_item;
|
||||
/* XXX The following multiplication and division does not optimize away
|
||||
like it does for lists since the size is not known at compile time */
|
||||
|
@ -84,7 +84,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
|||
return -1;
|
||||
}
|
||||
self->ob_item = items;
|
||||
Py_Size(self) = newsize;
|
||||
Py_SIZE(self) = newsize;
|
||||
self->allocated = _new_size;
|
||||
return 0;
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr)
|
|||
if (op == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
Py_Size(op) = size;
|
||||
Py_SIZE(op) = size;
|
||||
if (size <= 0) {
|
||||
op->ob_item = NULL;
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ getarrayitem(PyObject *op, Py_ssize_t i)
|
|||
register arrayobject *ap;
|
||||
assert(array_Check(op));
|
||||
ap = (arrayobject *)op;
|
||||
assert(i>=0 && i<Py_Size(ap));
|
||||
assert(i>=0 && i<Py_SIZE(ap));
|
||||
return (*ap->ob_descr->getitem)(ap, i);
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ static int
|
|||
ins1(arrayobject *self, Py_ssize_t where, PyObject *v)
|
||||
{
|
||||
char *items;
|
||||
Py_ssize_t n = Py_Size(self);
|
||||
Py_ssize_t n = Py_SIZE(self);
|
||||
if (v == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
|
@ -498,7 +498,7 @@ array_dealloc(arrayobject *op)
|
|||
PyObject_ClearWeakRefs((PyObject *) op);
|
||||
if (op->ob_item != NULL)
|
||||
PyMem_DEL(op->ob_item);
|
||||
Py_Type(op)->tp_free((PyObject *)op);
|
||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -518,7 +518,7 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
va = (arrayobject *)v;
|
||||
wa = (arrayobject *)w;
|
||||
|
||||
if (Py_Size(va) != Py_Size(wa) && (op == Py_EQ || op == Py_NE)) {
|
||||
if (Py_SIZE(va) != Py_SIZE(wa) && (op == Py_EQ || op == Py_NE)) {
|
||||
/* Shortcut: if the lengths differ, the arrays differ */
|
||||
if (op == Py_EQ)
|
||||
res = Py_False;
|
||||
|
@ -530,7 +530,7 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
|
||||
/* Search for the first index where items are different */
|
||||
k = 1;
|
||||
for (i = 0; i < Py_Size(va) && i < Py_Size(wa); i++) {
|
||||
for (i = 0; i < Py_SIZE(va) && i < Py_SIZE(wa); i++) {
|
||||
vi = getarrayitem(v, i);
|
||||
wi = getarrayitem(w, i);
|
||||
if (vi == NULL || wi == NULL) {
|
||||
|
@ -549,8 +549,8 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
|
||||
if (k) {
|
||||
/* No more items to compare -- compare sizes */
|
||||
Py_ssize_t vs = Py_Size(va);
|
||||
Py_ssize_t ws = Py_Size(wa);
|
||||
Py_ssize_t vs = Py_SIZE(va);
|
||||
Py_ssize_t ws = Py_SIZE(wa);
|
||||
int cmp;
|
||||
switch (op) {
|
||||
case Py_LT: cmp = vs < ws; break;
|
||||
|
@ -590,13 +590,13 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
static Py_ssize_t
|
||||
array_length(arrayobject *a)
|
||||
{
|
||||
return Py_Size(a);
|
||||
return Py_SIZE(a);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
array_item(arrayobject *a, Py_ssize_t i)
|
||||
{
|
||||
if (i < 0 || i >= Py_Size(a)) {
|
||||
if (i < 0 || i >= Py_SIZE(a)) {
|
||||
PyErr_SetString(PyExc_IndexError, "array index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -609,14 +609,14 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
|
|||
arrayobject *np;
|
||||
if (ilow < 0)
|
||||
ilow = 0;
|
||||
else if (ilow > Py_Size(a))
|
||||
ilow = Py_Size(a);
|
||||
else if (ilow > Py_SIZE(a))
|
||||
ilow = Py_SIZE(a);
|
||||
if (ihigh < 0)
|
||||
ihigh = 0;
|
||||
if (ihigh < ilow)
|
||||
ihigh = ilow;
|
||||
else if (ihigh > Py_Size(a))
|
||||
ihigh = Py_Size(a);
|
||||
else if (ihigh > Py_SIZE(a))
|
||||
ihigh = Py_SIZE(a);
|
||||
np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr);
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
|
@ -628,7 +628,7 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
|
|||
static PyObject *
|
||||
array_copy(arrayobject *a, PyObject *unused)
|
||||
{
|
||||
return array_slice(a, 0, Py_Size(a));
|
||||
return array_slice(a, 0, Py_SIZE(a));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(copy_doc,
|
||||
|
@ -644,7 +644,7 @@ array_concat(arrayobject *a, PyObject *bb)
|
|||
if (!array_Check(bb)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only append array (not \"%.200s\") to array",
|
||||
Py_Type(bb)->tp_name);
|
||||
Py_TYPE(bb)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
#define b ((arrayobject *)bb)
|
||||
|
@ -652,14 +652,14 @@ array_concat(arrayobject *a, PyObject *bb)
|
|||
PyErr_BadArgument();
|
||||
return NULL;
|
||||
}
|
||||
size = Py_Size(a) + Py_Size(b);
|
||||
size = Py_SIZE(a) + Py_SIZE(b);
|
||||
np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
|
||||
if (np == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memcpy(np->ob_item, a->ob_item, Py_Size(a)*a->ob_descr->itemsize);
|
||||
memcpy(np->ob_item + Py_Size(a)*a->ob_descr->itemsize,
|
||||
b->ob_item, Py_Size(b)*b->ob_descr->itemsize);
|
||||
memcpy(np->ob_item, a->ob_item, Py_SIZE(a)*a->ob_descr->itemsize);
|
||||
memcpy(np->ob_item + Py_SIZE(a)*a->ob_descr->itemsize,
|
||||
b->ob_item, Py_SIZE(b)*b->ob_descr->itemsize);
|
||||
return (PyObject *)np;
|
||||
#undef b
|
||||
}
|
||||
|
@ -674,12 +674,12 @@ array_repeat(arrayobject *a, Py_ssize_t n)
|
|||
Py_ssize_t nbytes;
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
size = Py_Size(a) * n;
|
||||
size = Py_SIZE(a) * n;
|
||||
np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
p = np->ob_item;
|
||||
nbytes = Py_Size(a) * a->ob_descr->itemsize;
|
||||
nbytes = Py_SIZE(a) * a->ob_descr->itemsize;
|
||||
for (i = 0; i < n; i++) {
|
||||
memcpy(p, a->ob_item, nbytes);
|
||||
p += nbytes;
|
||||
|
@ -697,7 +697,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
if (v == NULL)
|
||||
n = 0;
|
||||
else if (array_Check(v)) {
|
||||
n = Py_Size(b);
|
||||
n = Py_SIZE(b);
|
||||
if (a == b) {
|
||||
/* Special case "a[i:j] = a" -- copy b first */
|
||||
int ret;
|
||||
|
@ -716,44 +716,44 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only assign array (not \"%.200s\") to array slice",
|
||||
Py_Type(v)->tp_name);
|
||||
Py_TYPE(v)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (ilow < 0)
|
||||
ilow = 0;
|
||||
else if (ilow > Py_Size(a))
|
||||
ilow = Py_Size(a);
|
||||
else if (ilow > Py_SIZE(a))
|
||||
ilow = Py_SIZE(a);
|
||||
if (ihigh < 0)
|
||||
ihigh = 0;
|
||||
if (ihigh < ilow)
|
||||
ihigh = ilow;
|
||||
else if (ihigh > Py_Size(a))
|
||||
ihigh = Py_Size(a);
|
||||
else if (ihigh > Py_SIZE(a))
|
||||
ihigh = Py_SIZE(a);
|
||||
item = a->ob_item;
|
||||
d = n - (ihigh-ilow);
|
||||
if (d < 0) { /* Delete -d items */
|
||||
memmove(item + (ihigh+d)*a->ob_descr->itemsize,
|
||||
item + ihigh*a->ob_descr->itemsize,
|
||||
(Py_Size(a)-ihigh)*a->ob_descr->itemsize);
|
||||
Py_Size(a) += d;
|
||||
PyMem_RESIZE(item, char, Py_Size(a)*a->ob_descr->itemsize);
|
||||
(Py_SIZE(a)-ihigh)*a->ob_descr->itemsize);
|
||||
Py_SIZE(a) += d;
|
||||
PyMem_RESIZE(item, char, Py_SIZE(a)*a->ob_descr->itemsize);
|
||||
/* Can't fail */
|
||||
a->ob_item = item;
|
||||
a->allocated = Py_Size(a);
|
||||
a->allocated = Py_SIZE(a);
|
||||
}
|
||||
else if (d > 0) { /* Insert d items */
|
||||
PyMem_RESIZE(item, char,
|
||||
(Py_Size(a) + d)*a->ob_descr->itemsize);
|
||||
(Py_SIZE(a) + d)*a->ob_descr->itemsize);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return -1;
|
||||
}
|
||||
memmove(item + (ihigh+d)*a->ob_descr->itemsize,
|
||||
item + ihigh*a->ob_descr->itemsize,
|
||||
(Py_Size(a)-ihigh)*a->ob_descr->itemsize);
|
||||
(Py_SIZE(a)-ihigh)*a->ob_descr->itemsize);
|
||||
a->ob_item = item;
|
||||
Py_Size(a) += d;
|
||||
a->allocated = Py_Size(a);
|
||||
Py_SIZE(a) += d;
|
||||
a->allocated = Py_SIZE(a);
|
||||
}
|
||||
if (n > 0)
|
||||
memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item,
|
||||
|
@ -765,7 +765,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
static int
|
||||
array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v)
|
||||
{
|
||||
if (i < 0 || i >= Py_Size(a)) {
|
||||
if (i < 0 || i >= Py_SIZE(a)) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"array assignment index out of range");
|
||||
return -1;
|
||||
|
@ -792,7 +792,7 @@ array_iter_extend(arrayobject *self, PyObject *bb)
|
|||
return -1;
|
||||
|
||||
while ((v = PyIter_Next(it)) != NULL) {
|
||||
if (ins1(self, (int) Py_Size(self), v) != 0) {
|
||||
if (ins1(self, (int) Py_SIZE(self), v) != 0) {
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(it);
|
||||
return -1;
|
||||
|
@ -818,16 +818,16 @@ array_do_extend(arrayobject *self, PyObject *bb)
|
|||
"can only extend with array of same kind");
|
||||
return -1;
|
||||
}
|
||||
size = Py_Size(self) + Py_Size(b);
|
||||
size = Py_SIZE(self) + Py_SIZE(b);
|
||||
PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize);
|
||||
if (self->ob_item == NULL) {
|
||||
PyObject_Del(self);
|
||||
PyErr_NoMemory();
|
||||
return -1;
|
||||
}
|
||||
memcpy(self->ob_item + Py_Size(self)*self->ob_descr->itemsize,
|
||||
b->ob_item, Py_Size(b)*b->ob_descr->itemsize);
|
||||
Py_Size(self) = size;
|
||||
memcpy(self->ob_item + Py_SIZE(self)*self->ob_descr->itemsize,
|
||||
b->ob_item, Py_SIZE(b)*b->ob_descr->itemsize);
|
||||
Py_SIZE(self) = size;
|
||||
self->allocated = size;
|
||||
|
||||
return 0;
|
||||
|
@ -840,7 +840,7 @@ array_inplace_concat(arrayobject *self, PyObject *bb)
|
|||
if (!array_Check(bb)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only extend array with array (not \"%.200s\")",
|
||||
Py_Type(bb)->tp_name);
|
||||
Py_TYPE(bb)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
if (array_do_extend(self, bb) == -1)
|
||||
|
@ -855,15 +855,15 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n)
|
|||
char *items, *p;
|
||||
Py_ssize_t size, i;
|
||||
|
||||
if (Py_Size(self) > 0) {
|
||||
if (Py_SIZE(self) > 0) {
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
items = self->ob_item;
|
||||
size = Py_Size(self) * self->ob_descr->itemsize;
|
||||
size = Py_SIZE(self) * self->ob_descr->itemsize;
|
||||
if (n == 0) {
|
||||
PyMem_FREE(items);
|
||||
self->ob_item = NULL;
|
||||
Py_Size(self) = 0;
|
||||
Py_SIZE(self) = 0;
|
||||
self->allocated = 0;
|
||||
}
|
||||
else {
|
||||
|
@ -876,8 +876,8 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n)
|
|||
memcpy(p, items, size);
|
||||
}
|
||||
self->ob_item = items;
|
||||
Py_Size(self) *= n;
|
||||
self->allocated = Py_Size(self);
|
||||
Py_SIZE(self) *= n;
|
||||
self->allocated = Py_SIZE(self);
|
||||
}
|
||||
}
|
||||
Py_INCREF(self);
|
||||
|
@ -900,7 +900,7 @@ array_count(arrayobject *self, PyObject *v)
|
|||
Py_ssize_t count = 0;
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
for (i = 0; i < Py_SIZE(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self, i);
|
||||
int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -922,7 +922,7 @@ array_index(arrayobject *self, PyObject *v)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
for (i = 0; i < Py_SIZE(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self, i);
|
||||
int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -947,7 +947,7 @@ array_contains(arrayobject *self, PyObject *v)
|
|||
Py_ssize_t i;
|
||||
int cmp;
|
||||
|
||||
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(self); i++) {
|
||||
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self, i);
|
||||
cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -960,7 +960,7 @@ array_remove(arrayobject *self, PyObject *v)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
for (i = 0; i < Py_SIZE(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self,i);
|
||||
int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -990,14 +990,14 @@ array_pop(arrayobject *self, PyObject *args)
|
|||
PyObject *v;
|
||||
if (!PyArg_ParseTuple(args, "|n:pop", &i))
|
||||
return NULL;
|
||||
if (Py_Size(self) == 0) {
|
||||
if (Py_SIZE(self) == 0) {
|
||||
/* Special-case most common failure cause */
|
||||
PyErr_SetString(PyExc_IndexError, "pop from empty array");
|
||||
return NULL;
|
||||
}
|
||||
if (i < 0)
|
||||
i += Py_Size(self);
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
i += Py_SIZE(self);
|
||||
if (i < 0 || i >= Py_SIZE(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "pop index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1053,7 +1053,7 @@ array_buffer_info(arrayobject *self, PyObject *unused)
|
|||
return NULL;
|
||||
|
||||
PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item));
|
||||
PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_Size(self))));
|
||||
PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_SIZE(self))));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ the buffer length in bytes.");
|
|||
static PyObject *
|
||||
array_append(arrayobject *self, PyObject *v)
|
||||
{
|
||||
return ins(self, (int) Py_Size(self), v);
|
||||
return ins(self, (int) Py_SIZE(self), v);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(append_doc,
|
||||
|
@ -1089,14 +1089,14 @@ array_byteswap(arrayobject *self, PyObject *unused)
|
|||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 2) {
|
||||
for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 2) {
|
||||
char p0 = p[0];
|
||||
p[0] = p[1];
|
||||
p[1] = p0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 4) {
|
||||
for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 4) {
|
||||
char p0 = p[0];
|
||||
char p1 = p[1];
|
||||
p[0] = p[3];
|
||||
|
@ -1106,7 +1106,7 @@ array_byteswap(arrayobject *self, PyObject *unused)
|
|||
}
|
||||
break;
|
||||
case 8:
|
||||
for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 8) {
|
||||
for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 8) {
|
||||
char p0 = p[0];
|
||||
char p1 = p[1];
|
||||
char p2 = p[2];
|
||||
|
@ -1147,16 +1147,16 @@ array_reduce(arrayobject *array)
|
|||
dict = Py_None;
|
||||
Py_INCREF(dict);
|
||||
}
|
||||
if (Py_Size(array) > 0) {
|
||||
if (Py_SIZE(array) > 0) {
|
||||
result = Py_BuildValue("O(cs#)O",
|
||||
Py_Type(array),
|
||||
Py_TYPE(array),
|
||||
array->ob_descr->typecode,
|
||||
array->ob_item,
|
||||
Py_Size(array) * array->ob_descr->itemsize,
|
||||
Py_SIZE(array) * array->ob_descr->itemsize,
|
||||
dict);
|
||||
} else {
|
||||
result = Py_BuildValue("O(c)O",
|
||||
Py_Type(array),
|
||||
Py_TYPE(array),
|
||||
array->ob_descr->typecode,
|
||||
dict);
|
||||
}
|
||||
|
@ -1175,9 +1175,9 @@ array_reverse(arrayobject *self, PyObject *unused)
|
|||
char tmp[256]; /* 8 is probably enough -- but why skimp */
|
||||
assert((size_t)itemsize <= sizeof(tmp));
|
||||
|
||||
if (Py_Size(self) > 1) {
|
||||
if (Py_SIZE(self) > 1) {
|
||||
for (p = self->ob_item,
|
||||
q = self->ob_item + (Py_Size(self) - 1)*itemsize;
|
||||
q = self->ob_item + (Py_SIZE(self) - 1)*itemsize;
|
||||
p < q;
|
||||
p += itemsize, q -= itemsize) {
|
||||
/* memory areas guaranteed disjoint, so memcpy
|
||||
|
@ -1218,7 +1218,7 @@ array_fromfile(arrayobject *self, PyObject *args)
|
|||
Py_ssize_t newlength;
|
||||
size_t newbytes;
|
||||
/* Be careful here about overflow */
|
||||
if ((newlength = Py_Size(self) + n) <= 0 ||
|
||||
if ((newlength = Py_SIZE(self) + n) <= 0 ||
|
||||
(newbytes = newlength * itemsize) / itemsize !=
|
||||
(size_t)newlength)
|
||||
goto nomem;
|
||||
|
@ -1229,15 +1229,15 @@ array_fromfile(arrayobject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
nread = fread(item + (Py_Size(self) - n) * itemsize,
|
||||
Py_SIZE(self) += n;
|
||||
self->allocated = Py_SIZE(self);
|
||||
nread = fread(item + (Py_SIZE(self) - n) * itemsize,
|
||||
itemsize, n, fp);
|
||||
if (nread < (size_t)n) {
|
||||
Py_Size(self) -= (n - nread);
|
||||
PyMem_RESIZE(item, char, Py_Size(self)*itemsize);
|
||||
Py_SIZE(self) -= (n - nread);
|
||||
PyMem_RESIZE(item, char, Py_SIZE(self)*itemsize);
|
||||
self->ob_item = item;
|
||||
self->allocated = Py_Size(self);
|
||||
self->allocated = Py_SIZE(self);
|
||||
PyErr_SetString(PyExc_EOFError,
|
||||
"not enough items in file");
|
||||
return NULL;
|
||||
|
@ -1297,23 +1297,23 @@ array_fromlist(arrayobject *self, PyObject *list)
|
|||
if (n > 0) {
|
||||
char *item = self->ob_item;
|
||||
Py_ssize_t i;
|
||||
PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize);
|
||||
PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
Py_SIZE(self) += n;
|
||||
self->allocated = Py_SIZE(self);
|
||||
for (i = 0; i < n; i++) {
|
||||
PyObject *v = PyList_GetItem(list, i);
|
||||
if ((*self->ob_descr->setitem)(self,
|
||||
Py_Size(self) - n + i, v) != 0) {
|
||||
Py_Size(self) -= n;
|
||||
Py_SIZE(self) - n + i, v) != 0) {
|
||||
Py_SIZE(self) -= n;
|
||||
PyMem_RESIZE(item, char,
|
||||
Py_Size(self) * itemsize);
|
||||
Py_SIZE(self) * itemsize);
|
||||
self->ob_item = item;
|
||||
self->allocated = Py_Size(self);
|
||||
self->allocated = Py_SIZE(self);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1331,12 +1331,12 @@ Append items to array from list.");
|
|||
static PyObject *
|
||||
array_tolist(arrayobject *self, PyObject *unused)
|
||||
{
|
||||
PyObject *list = PyList_New(Py_Size(self));
|
||||
PyObject *list = PyList_New(Py_SIZE(self));
|
||||
Py_ssize_t i;
|
||||
|
||||
if (list == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
for (i = 0; i < Py_SIZE(self); i++) {
|
||||
PyObject *v = getarrayitem((PyObject *)self, i);
|
||||
if (v == NULL) {
|
||||
Py_DECREF(list);
|
||||
|
@ -1369,15 +1369,15 @@ array_fromstring(arrayobject *self, PyObject *args)
|
|||
n = n / itemsize;
|
||||
if (n > 0) {
|
||||
char *item = self->ob_item;
|
||||
PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize);
|
||||
PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
memcpy(item + (Py_Size(self) - n) * itemsize,
|
||||
Py_SIZE(self) += n;
|
||||
self->allocated = Py_SIZE(self);
|
||||
memcpy(item + (Py_SIZE(self) - n) * itemsize,
|
||||
str, itemsize*n);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -1395,7 +1395,7 @@ static PyObject *
|
|||
array_tostring(arrayobject *self, PyObject *unused)
|
||||
{
|
||||
return PyString_FromStringAndSize(self->ob_item,
|
||||
Py_Size(self) * self->ob_descr->itemsize);
|
||||
Py_SIZE(self) * self->ob_descr->itemsize);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(tostring_doc,
|
||||
|
@ -1423,15 +1423,15 @@ array_fromunicode(arrayobject *self, PyObject *args)
|
|||
}
|
||||
if (n > 0) {
|
||||
Py_UNICODE *item = (Py_UNICODE *) self->ob_item;
|
||||
PyMem_RESIZE(item, Py_UNICODE, Py_Size(self) + n);
|
||||
PyMem_RESIZE(item, Py_UNICODE, Py_SIZE(self) + n);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
self->ob_item = (char *) item;
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
memcpy(item + Py_Size(self) - n,
|
||||
Py_SIZE(self) += n;
|
||||
self->allocated = Py_SIZE(self);
|
||||
memcpy(item + Py_SIZE(self) - n,
|
||||
ustr, n * sizeof(Py_UNICODE));
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1456,7 @@ array_tounicode(arrayobject *self, PyObject *unused)
|
|||
"tounicode() may only be called on type 'u' arrays");
|
||||
return NULL;
|
||||
}
|
||||
return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_Size(self));
|
||||
return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_SIZE(self));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(tounicode_doc,
|
||||
|
@ -1554,7 +1554,7 @@ array_repr(arrayobject *a)
|
|||
PyObject *s, *t, *v = NULL;
|
||||
Py_ssize_t len;
|
||||
|
||||
len = Py_Size(a);
|
||||
len = Py_SIZE(a);
|
||||
typecode = a->ob_descr->typecode;
|
||||
if (len == 0) {
|
||||
PyOS_snprintf(buf, sizeof(buf), "array('%c')", typecode);
|
||||
|
@ -1588,7 +1588,7 @@ array_subscr(arrayobject* self, PyObject* item)
|
|||
return NULL;
|
||||
}
|
||||
if (i < 0)
|
||||
i += Py_Size(self);
|
||||
i += Py_SIZE(self);
|
||||
return array_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
|
@ -1597,7 +1597,7 @@ array_subscr(arrayobject* self, PyObject* item)
|
|||
arrayobject* ar;
|
||||
int itemsize = self->ob_descr->itemsize;
|
||||
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
|
||||
&start, &stop, &step, &slicelength) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1651,8 +1651,8 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
if (i == -1 && PyErr_Occurred())
|
||||
return -1;
|
||||
if (i < 0)
|
||||
i += Py_Size(self);
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
i += Py_SIZE(self);
|
||||
if (i < 0 || i >= Py_SIZE(self)) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"array assignment index out of range");
|
||||
return -1;
|
||||
|
@ -1669,7 +1669,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
if (PySlice_GetIndicesEx((PySliceObject *)item,
|
||||
Py_Size(self), &start, &stop,
|
||||
Py_SIZE(self), &start, &stop,
|
||||
&step, &slicelength) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1685,7 +1685,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
}
|
||||
else if (array_Check(value)) {
|
||||
other = (arrayobject *)value;
|
||||
needed = Py_Size(other);
|
||||
needed = Py_SIZE(other);
|
||||
if (self == other) {
|
||||
/* Special case "self[i:j] = self" -- copy self first */
|
||||
int ret;
|
||||
|
@ -1704,7 +1704,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only assign array (not \"%.200s\") to array slice",
|
||||
Py_Type(value)->tp_name);
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
itemsize = self->ob_descr->itemsize;
|
||||
|
@ -1716,18 +1716,18 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
if (slicelength > needed) {
|
||||
memmove(self->ob_item + (start + needed) * itemsize,
|
||||
self->ob_item + stop * itemsize,
|
||||
(Py_Size(self) - stop) * itemsize);
|
||||
if (array_resize(self, Py_Size(self) +
|
||||
(Py_SIZE(self) - stop) * itemsize);
|
||||
if (array_resize(self, Py_SIZE(self) +
|
||||
needed - slicelength) < 0)
|
||||
return -1;
|
||||
}
|
||||
else if (slicelength < needed) {
|
||||
if (array_resize(self, Py_Size(self) +
|
||||
if (array_resize(self, Py_SIZE(self) +
|
||||
needed - slicelength) < 0)
|
||||
return -1;
|
||||
memmove(self->ob_item + (start + needed) * itemsize,
|
||||
self->ob_item + stop * itemsize,
|
||||
(Py_Size(self) - start - needed) * itemsize);
|
||||
(Py_SIZE(self) - start - needed) * itemsize);
|
||||
}
|
||||
if (needed > 0)
|
||||
memcpy(self->ob_item + start * itemsize,
|
||||
|
@ -1747,19 +1747,19 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
cur += step, i++) {
|
||||
Py_ssize_t lim = step - 1;
|
||||
|
||||
if (cur + step >= Py_Size(self))
|
||||
lim = Py_Size(self) - cur - 1;
|
||||
if (cur + step >= Py_SIZE(self))
|
||||
lim = Py_SIZE(self) - cur - 1;
|
||||
memmove(self->ob_item + (cur - i) * itemsize,
|
||||
self->ob_item + (cur + 1) * itemsize,
|
||||
lim * itemsize);
|
||||
}
|
||||
cur = start + slicelength * step;
|
||||
if (cur < Py_Size(self)) {
|
||||
if (cur < Py_SIZE(self)) {
|
||||
memmove(self->ob_item + (cur-slicelength) * itemsize,
|
||||
self->ob_item + cur * itemsize,
|
||||
(Py_Size(self) - cur) * itemsize);
|
||||
(Py_SIZE(self) - cur) * itemsize);
|
||||
}
|
||||
if (array_resize(self, Py_Size(self) - slicelength) < 0)
|
||||
if (array_resize(self, Py_SIZE(self) - slicelength) < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1802,7 +1802,7 @@ array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = (void *)self->ob_item;
|
||||
if (*ptr == NULL)
|
||||
*ptr = emptybuf;
|
||||
return Py_Size(self)*self->ob_descr->itemsize;
|
||||
return Py_SIZE(self)*self->ob_descr->itemsize;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
|
@ -1816,14 +1816,14 @@ array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = (void *)self->ob_item;
|
||||
if (*ptr == NULL)
|
||||
*ptr = emptybuf;
|
||||
return Py_Size(self)*self->ob_descr->itemsize;
|
||||
return Py_SIZE(self)*self->ob_descr->itemsize;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
array_buffer_getsegcount(arrayobject *self, Py_ssize_t *lenp)
|
||||
{
|
||||
if ( lenp )
|
||||
*lenp = Py_Size(self)*self->ob_descr->itemsize;
|
||||
*lenp = Py_SIZE(self)*self->ob_descr->itemsize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1932,9 +1932,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
Py_Size(self) = n / sizeof(Py_UNICODE);
|
||||
Py_SIZE(self) = n / sizeof(Py_UNICODE);
|
||||
memcpy(item, PyUnicode_AS_DATA(initial), n);
|
||||
self->allocated = Py_Size(self);
|
||||
self->allocated = Py_SIZE(self);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -2103,7 +2103,7 @@ static PyObject *
|
|||
arrayiter_next(arrayiterobject *it)
|
||||
{
|
||||
assert(PyArrayIter_Check(it));
|
||||
if (it->index < Py_Size(it->ao))
|
||||
if (it->index < Py_SIZE(it->ao))
|
||||
return (*it->getitem)(it->ao, it->index++);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef fpos_t Py_off_t;
|
|||
#define MODE_READ_EOF 2
|
||||
#define MODE_WRITE 3
|
||||
|
||||
#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type)
|
||||
#define BZ2FileObject_Check(v) (Py_TYPE(v) == &BZ2File_Type)
|
||||
|
||||
|
||||
#ifdef BZ_CONFIG_ERROR
|
||||
|
@ -1412,7 +1412,7 @@ BZ2File_dealloc(BZ2FileObject *self)
|
|||
}
|
||||
Util_DropReadAhead(self);
|
||||
Py_XDECREF(self->file);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
/* This is a hacked version of Python's fileobject.c:file_getiter(). */
|
||||
|
@ -1728,7 +1728,7 @@ BZ2Comp_dealloc(BZ2CompObject *self)
|
|||
PyThread_free_lock(self->lock);
|
||||
#endif
|
||||
BZ2_bzCompressEnd(&self->bzs);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1950,7 +1950,7 @@ BZ2Decomp_dealloc(BZ2DecompObject *self)
|
|||
#endif
|
||||
Py_XDECREF(self->unused_data);
|
||||
BZ2_bzDecompressEnd(&self->bzs);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2200,9 +2200,9 @@ initbz2(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
Py_Type(&BZ2File_Type) = &PyType_Type;
|
||||
Py_Type(&BZ2Comp_Type) = &PyType_Type;
|
||||
Py_Type(&BZ2Decomp_Type) = &PyType_Type;
|
||||
Py_TYPE(&BZ2File_Type) = &PyType_Type;
|
||||
Py_TYPE(&BZ2Comp_Type) = &PyType_Type;
|
||||
Py_TYPE(&BZ2Decomp_Type) = &PyType_Type;
|
||||
|
||||
m = Py_InitModule3("bz2", bz2_methods, bz2__doc__);
|
||||
if (m == NULL)
|
||||
|
|
|
@ -156,7 +156,7 @@ static PyTypeObject PdataType = {
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0L,0L,0L,0L, ""
|
||||
};
|
||||
|
||||
#define Pdata_Check(O) (Py_Type(O) == &PdataType)
|
||||
#define Pdata_Check(O) (Py_TYPE(O) == &PdataType)
|
||||
|
||||
static PyObject *
|
||||
Pdata_New(void)
|
||||
|
@ -316,7 +316,7 @@ Pdata_popList(Pdata *self, int start)
|
|||
}
|
||||
|
||||
#define FREE_ARG_TUP(self) { \
|
||||
if (Py_Refcnt(self->arg) > 1) { \
|
||||
if (Py_REFCNT(self->arg) > 1) { \
|
||||
Py_DECREF(self->arg); \
|
||||
self->arg=NULL; \
|
||||
} \
|
||||
|
@ -752,7 +752,7 @@ get(Picklerobject *self, PyObject *id)
|
|||
static int
|
||||
put(Picklerobject *self, PyObject *ob)
|
||||
{
|
||||
if (Py_Refcnt(ob) < 2 || self->fast)
|
||||
if (Py_REFCNT(ob) < 2 || self->fast)
|
||||
return 0;
|
||||
|
||||
return put2(self, ob);
|
||||
|
@ -916,7 +916,7 @@ fast_save_enter(Picklerobject *self, PyObject *obj)
|
|||
PyErr_Format(PyExc_ValueError,
|
||||
"fast mode: can't pickle cyclic objects "
|
||||
"including object type %s at %p",
|
||||
Py_Type(obj)->tp_name, obj);
|
||||
Py_TYPE(obj)->tp_name, obj);
|
||||
self->fast_container = -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2320,7 +2320,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
|||
goto finally;
|
||||
}
|
||||
|
||||
type = Py_Type(args);
|
||||
type = Py_TYPE(args);
|
||||
|
||||
switch (type->tp_name[0]) {
|
||||
case 'b':
|
||||
|
@ -2372,7 +2372,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
|
|||
#endif
|
||||
}
|
||||
|
||||
if (Py_Refcnt(args) > 1) {
|
||||
if (Py_REFCNT(args) > 1) {
|
||||
if (!( py_ob_id = PyLong_FromVoidPtr(args)))
|
||||
goto finally;
|
||||
|
||||
|
@ -2913,7 +2913,7 @@ Pickler_dealloc(Picklerobject *self)
|
|||
Py_XDECREF(self->inst_pers_func);
|
||||
Py_XDECREF(self->dispatch_table);
|
||||
PyMem_Free(self->write_buf);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -5253,7 +5253,7 @@ Unpickler_dealloc(Unpicklerobject *self)
|
|||
free(self->buf);
|
||||
}
|
||||
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -5706,9 +5706,9 @@ initcPickle(void)
|
|||
PyObject *format_version;
|
||||
PyObject *compatible_formats;
|
||||
|
||||
Py_Type(&Picklertype) = &PyType_Type;
|
||||
Py_Type(&Unpicklertype) = &PyType_Type;
|
||||
Py_Type(&PdataType) = &PyType_Type;
|
||||
Py_TYPE(&Picklertype) = &PyType_Type;
|
||||
Py_TYPE(&Unpicklertype) = &PyType_Type;
|
||||
Py_TYPE(&PdataType) = &PyType_Type;
|
||||
|
||||
/* Initialize some pieces. We need to do this before module creation,
|
||||
* so we're forced to use a temporary dictionary. :(
|
||||
|
|
|
@ -747,8 +747,8 @@ initcStringIO(void) {
|
|||
d = PyModule_GetDict(m);
|
||||
|
||||
/* Export C API */
|
||||
Py_Type(&Itype)=&PyType_Type;
|
||||
Py_Type(&Otype)=&PyType_Type;
|
||||
Py_TYPE(&Itype)=&PyType_Type;
|
||||
Py_TYPE(&Otype)=&PyType_Type;
|
||||
if (PyType_Ready(&Otype) < 0) return;
|
||||
if (PyType_Ready(&Itype) < 0) return;
|
||||
PyDict_SetItemString(d,"cStringIO_CAPI",
|
||||
|
|
|
@ -945,7 +945,7 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self)
|
|||
{
|
||||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_Type(self)->tp_free(self);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject MultibyteIncrementalEncoder_Type = {
|
||||
|
@ -1145,7 +1145,7 @@ mbidecoder_dealloc(MultibyteIncrementalDecoderObject *self)
|
|||
{
|
||||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_Type(self)->tp_free(self);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject MultibyteIncrementalDecoder_Type = {
|
||||
|
@ -1461,7 +1461,7 @@ mbstreamreader_dealloc(MultibyteStreamReaderObject *self)
|
|||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_DECREF(self->stream);
|
||||
Py_Type(self)->tp_free(self);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject MultibyteStreamReader_Type = {
|
||||
|
@ -1663,7 +1663,7 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self)
|
|||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_DECREF(self->stream);
|
||||
Py_Type(self)->tp_free(self);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static struct PyMethodDef mbstreamwriter_methods[] = {
|
||||
|
|
|
@ -764,7 +764,7 @@ check_tzinfo_subclass(PyObject *p)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"tzinfo argument must be None or of a tzinfo subclass, "
|
||||
"not type '%s'",
|
||||
Py_Type(p)->tp_name);
|
||||
Py_TYPE(p)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -855,7 +855,7 @@ call_utc_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg,
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"tzinfo.%s() must return None or "
|
||||
"timedelta, not '%s'",
|
||||
name, Py_Type(u)->tp_name);
|
||||
name, Py_TYPE(u)->tp_name);
|
||||
}
|
||||
|
||||
Py_DECREF(u);
|
||||
|
@ -948,7 +948,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
|
|||
if (result != NULL && result != Py_None && ! PyString_Check(result)) {
|
||||
PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must "
|
||||
"return None or a string, not '%s'",
|
||||
Py_Type(result)->tp_name);
|
||||
Py_TYPE(result)->tp_name);
|
||||
Py_DECREF(result);
|
||||
result = NULL;
|
||||
}
|
||||
|
@ -1421,7 +1421,7 @@ cmperror(PyObject *a, PyObject *b)
|
|||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can't compare %s to %s",
|
||||
Py_Type(a)->tp_name, Py_Type(b)->tp_name);
|
||||
Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1876,7 +1876,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
|
|||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported type for timedelta %s component: %s",
|
||||
tag, Py_Type(num)->tp_name);
|
||||
tag, Py_TYPE(num)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1980,18 +1980,18 @@ delta_repr(PyDateTime_Delta *self)
|
|||
{
|
||||
if (GET_TD_MICROSECONDS(self) != 0)
|
||||
return PyString_FromFormat("%s(%d, %d, %d)",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
GET_TD_DAYS(self),
|
||||
GET_TD_SECONDS(self),
|
||||
GET_TD_MICROSECONDS(self));
|
||||
if (GET_TD_SECONDS(self) != 0)
|
||||
return PyString_FromFormat("%s(%d, %d)",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
GET_TD_DAYS(self),
|
||||
GET_TD_SECONDS(self));
|
||||
|
||||
return PyString_FromFormat("%s(%d)",
|
||||
Py_Type(self)->tp_name,
|
||||
Py_TYPE(self)->tp_name,
|
||||
GET_TD_DAYS(self));
|
||||
}
|
||||
|
||||
|
@ -2055,7 +2055,7 @@ delta_getstate(PyDateTime_Delta *self)
|
|||
static PyObject *
|
||||
delta_reduce(PyDateTime_Delta* self)
|
||||
{
|
||||
return Py_BuildValue("ON", Py_Type(self), delta_getstate(self));
|
||||
return Py_BuildValue("ON", Py_TYPE(self), delta_getstate(self));
|
||||
}
|
||||
|
||||
#define OFFSET(field) offsetof(PyDateTime_Delta, field)
|
||||
|
@ -2414,7 +2414,7 @@ date_repr(PyDateTime_Date *self)
|
|||
char buffer[1028];
|
||||
const char *type_name;
|
||||
|
||||
type_name = Py_Type(self)->tp_name;
|
||||
type_name = Py_TYPE(self)->tp_name;
|
||||
PyOS_snprintf(buffer, sizeof(buffer), "%s(%d, %d, %d)",
|
||||
type_name,
|
||||
GET_YEAR(self), GET_MONTH(self), GET_DAY(self));
|
||||
|
@ -2554,7 +2554,7 @@ date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw)
|
|||
tuple = Py_BuildValue("iii", year, month, day);
|
||||
if (tuple == NULL)
|
||||
return NULL;
|
||||
clone = date_new(Py_Type(self), tuple, NULL);
|
||||
clone = date_new(Py_TYPE(self), tuple, NULL);
|
||||
Py_DECREF(tuple);
|
||||
return clone;
|
||||
}
|
||||
|
@ -2604,7 +2604,7 @@ date_getstate(PyDateTime_Date *self)
|
|||
static PyObject *
|
||||
date_reduce(PyDateTime_Date *self, PyObject *arg)
|
||||
{
|
||||
return Py_BuildValue("(ON)", Py_Type(self), date_getstate(self));
|
||||
return Py_BuildValue("(ON)", Py_TYPE(self), date_getstate(self));
|
||||
}
|
||||
|
||||
static PyMethodDef date_methods[] = {
|
||||
|
@ -2906,10 +2906,10 @@ tzinfo_reduce(PyObject *self)
|
|||
|
||||
if (state == Py_None) {
|
||||
Py_DECREF(state);
|
||||
return Py_BuildValue("(ON)", Py_Type(self), args);
|
||||
return Py_BuildValue("(ON)", Py_TYPE(self), args);
|
||||
}
|
||||
else
|
||||
return Py_BuildValue("(ONN)", Py_Type(self), args, state);
|
||||
return Py_BuildValue("(ONN)", Py_TYPE(self), args, state);
|
||||
}
|
||||
|
||||
static PyMethodDef tzinfo_methods[] = {
|
||||
|
@ -3104,7 +3104,7 @@ time_dealloc(PyDateTime_Time *self)
|
|||
if (HASTZINFO(self)) {
|
||||
Py_XDECREF(self->tzinfo);
|
||||
}
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3138,7 +3138,7 @@ static PyObject *
|
|||
time_repr(PyDateTime_Time *self)
|
||||
{
|
||||
char buffer[100];
|
||||
const char *type_name = Py_Type(self)->tp_name;
|
||||
const char *type_name = Py_TYPE(self)->tp_name;
|
||||
int h = TIME_GET_HOUR(self);
|
||||
int m = TIME_GET_MINUTE(self);
|
||||
int s = TIME_GET_SECOND(self);
|
||||
|
@ -3352,7 +3352,7 @@ time_replace(PyDateTime_Time *self, PyObject *args, PyObject *kw)
|
|||
tuple = Py_BuildValue("iiiiO", hh, mm, ss, us, tzinfo);
|
||||
if (tuple == NULL)
|
||||
return NULL;
|
||||
clone = time_new(Py_Type(self), tuple, NULL);
|
||||
clone = time_new(Py_TYPE(self), tuple, NULL);
|
||||
Py_DECREF(tuple);
|
||||
return clone;
|
||||
}
|
||||
|
@ -3406,7 +3406,7 @@ time_getstate(PyDateTime_Time *self)
|
|||
static PyObject *
|
||||
time_reduce(PyDateTime_Time *self, PyObject *arg)
|
||||
{
|
||||
return Py_BuildValue("(ON)", Py_Type(self), time_getstate(self));
|
||||
return Py_BuildValue("(ON)", Py_TYPE(self), time_getstate(self));
|
||||
}
|
||||
|
||||
static PyMethodDef time_methods[] = {
|
||||
|
@ -3900,7 +3900,7 @@ datetime_dealloc(PyDateTime_DateTime *self)
|
|||
if (HASTZINFO(self)) {
|
||||
Py_XDECREF(self->tzinfo);
|
||||
}
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4049,7 +4049,7 @@ static PyObject *
|
|||
datetime_repr(PyDateTime_DateTime *self)
|
||||
{
|
||||
char buffer[1000];
|
||||
const char *type_name = Py_Type(self)->tp_name;
|
||||
const char *type_name = Py_TYPE(self)->tp_name;
|
||||
PyObject *baserepr;
|
||||
|
||||
if (DATE_GET_MICROSECOND(self)) {
|
||||
|
@ -4270,7 +4270,7 @@ datetime_replace(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
|
|||
tuple = Py_BuildValue("iiiiiiiO", y, m, d, hh, mm, ss, us, tzinfo);
|
||||
if (tuple == NULL)
|
||||
return NULL;
|
||||
clone = datetime_new(Py_Type(self), tuple, NULL);
|
||||
clone = datetime_new(Py_TYPE(self), tuple, NULL);
|
||||
Py_DECREF(tuple);
|
||||
return clone;
|
||||
}
|
||||
|
@ -4458,7 +4458,7 @@ datetime_getstate(PyDateTime_DateTime *self)
|
|||
static PyObject *
|
||||
datetime_reduce(PyDateTime_DateTime *self, PyObject *arg)
|
||||
{
|
||||
return Py_BuildValue("(ON)", Py_Type(self), datetime_getstate(self));
|
||||
return Py_BuildValue("(ON)", Py_TYPE(self), datetime_getstate(self));
|
||||
}
|
||||
|
||||
static PyMethodDef datetime_methods[] = {
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Dbmtype;
|
||||
|
||||
#define is_dbmobject(v) (Py_Type(v) == &Dbmtype)
|
||||
#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype)
|
||||
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
||||
{ PyErr_SetString(DbmError, "DBM object has already been closed"); \
|
||||
return NULL; }
|
||||
|
|
|
@ -62,7 +62,7 @@ dl_sym(dlobject *xp, PyObject *args)
|
|||
name = PyString_AS_STRING(args);
|
||||
} else {
|
||||
PyErr_Format(PyExc_TypeError, "expected string, found %.200s",
|
||||
Py_Type(args)->tp_name);
|
||||
Py_TYPE(args)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
func = dlsym(xp->dl_handle, name);
|
||||
|
@ -236,7 +236,7 @@ initdl(void)
|
|||
PyObject *m, *d, *x;
|
||||
|
||||
/* Initialize object type */
|
||||
Py_Type(&Dltype) = &PyType_Type;
|
||||
Py_TYPE(&Dltype) = &PyType_Type;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule("dl", dl_methods);
|
||||
|
|
|
@ -239,7 +239,7 @@ update_refs(PyGC_Head *containers)
|
|||
PyGC_Head *gc = containers->gc.gc_next;
|
||||
for (; gc != containers; gc = gc->gc.gc_next) {
|
||||
assert(gc->gc.gc_refs == GC_REACHABLE);
|
||||
gc->gc.gc_refs = Py_Refcnt(FROM_GC(gc));
|
||||
gc->gc.gc_refs = Py_REFCNT(FROM_GC(gc));
|
||||
/* Python's cyclic gc should never see an incoming refcount
|
||||
* of 0: if something decref'ed to 0, it should have been
|
||||
* deallocated immediately at that time.
|
||||
|
@ -291,7 +291,7 @@ subtract_refs(PyGC_Head *containers)
|
|||
traverseproc traverse;
|
||||
PyGC_Head *gc = containers->gc.gc_next;
|
||||
for (; gc != containers; gc=gc->gc.gc_next) {
|
||||
traverse = Py_Type(FROM_GC(gc))->tp_traverse;
|
||||
traverse = Py_TYPE(FROM_GC(gc))->tp_traverse;
|
||||
(void) traverse(FROM_GC(gc),
|
||||
(visitproc)visit_decref,
|
||||
NULL);
|
||||
|
@ -376,7 +376,7 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable)
|
|||
* the next object to visit.
|
||||
*/
|
||||
PyObject *op = FROM_GC(gc);
|
||||
traverseproc traverse = Py_Type(op)->tp_traverse;
|
||||
traverseproc traverse = Py_TYPE(op)->tp_traverse;
|
||||
assert(gc->gc.gc_refs > 0);
|
||||
gc->gc.gc_refs = GC_REACHABLE;
|
||||
(void) traverse(op,
|
||||
|
@ -472,7 +472,7 @@ move_finalizer_reachable(PyGC_Head *finalizers)
|
|||
PyGC_Head *gc = finalizers->gc.gc_next;
|
||||
for (; gc != finalizers; gc = gc->gc.gc_next) {
|
||||
/* Note that the finalizers list may grow during this. */
|
||||
traverse = Py_Type(FROM_GC(gc))->tp_traverse;
|
||||
traverse = Py_TYPE(FROM_GC(gc))->tp_traverse;
|
||||
(void) traverse(FROM_GC(gc),
|
||||
(visitproc)visit_move,
|
||||
(void *)finalizers);
|
||||
|
@ -517,7 +517,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
|
|||
assert(IS_TENTATIVELY_UNREACHABLE(op));
|
||||
next = gc->gc.gc_next;
|
||||
|
||||
if (! PyType_SUPPORTS_WEAKREFS(Py_Type(op)))
|
||||
if (! PyType_SUPPORTS_WEAKREFS(Py_TYPE(op)))
|
||||
continue;
|
||||
|
||||
/* It supports weakrefs. Does it have any? */
|
||||
|
@ -654,7 +654,7 @@ debug_cycle(char *msg, PyObject *op)
|
|||
}
|
||||
else if (debug & DEBUG_OBJECTS) {
|
||||
PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
|
||||
msg, Py_Type(op)->tp_name, op);
|
||||
msg, Py_TYPE(op)->tp_name, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ delete_garbage(PyGC_Head *collectable, PyGC_Head *old)
|
|||
PyList_Append(garbage, op);
|
||||
}
|
||||
else {
|
||||
if ((clear = Py_Type(op)->tp_clear) != NULL) {
|
||||
if ((clear = Py_TYPE(op)->tp_clear) != NULL) {
|
||||
Py_INCREF(op);
|
||||
clear(op);
|
||||
Py_DECREF(op);
|
||||
|
@ -1079,7 +1079,7 @@ gc_referrers_for(PyObject *objs, PyGC_Head *list, PyObject *resultlist)
|
|||
traverseproc traverse;
|
||||
for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) {
|
||||
obj = FROM_GC(gc);
|
||||
traverse = Py_Type(obj)->tp_traverse;
|
||||
traverse = Py_TYPE(obj)->tp_traverse;
|
||||
if (obj == objs || obj == resultlist)
|
||||
continue;
|
||||
if (traverse(obj, (visitproc)referrersvisit, objs)) {
|
||||
|
@ -1136,7 +1136,7 @@ gc_get_referents(PyObject *self, PyObject *args)
|
|||
|
||||
if (! PyObject_IS_GC(obj))
|
||||
continue;
|
||||
traverse = Py_Type(obj)->tp_traverse;
|
||||
traverse = Py_TYPE(obj)->tp_traverse;
|
||||
if (! traverse)
|
||||
continue;
|
||||
if (traverse(obj, (visitproc)referentsvisit, result)) {
|
||||
|
@ -1359,13 +1359,13 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
|
|||
PyVarObject *
|
||||
_PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
|
||||
{
|
||||
const size_t basicsize = _PyObject_VAR_SIZE(Py_Type(op), nitems);
|
||||
const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems);
|
||||
PyGC_Head *g = AS_GC(op);
|
||||
g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
|
||||
if (g == NULL)
|
||||
return (PyVarObject *)PyErr_NoMemory();
|
||||
op = (PyVarObject *) FROM_GC(g);
|
||||
Py_Size(op) = nitems;
|
||||
Py_SIZE(op) = nitems;
|
||||
return op;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Dbmtype;
|
||||
|
||||
#define is_dbmobject(v) (Py_Type(v) == &Dbmtype)
|
||||
#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype)
|
||||
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
||||
{ PyErr_SetString(DbmError, "GDBM object has already been closed"); \
|
||||
return NULL; }
|
||||
|
|
|
@ -59,7 +59,7 @@ groupby_dealloc(groupbyobject *gbo)
|
|||
Py_XDECREF(gbo->tgtkey);
|
||||
Py_XDECREF(gbo->currkey);
|
||||
Py_XDECREF(gbo->currvalue);
|
||||
Py_Type(gbo)->tp_free(gbo);
|
||||
Py_TYPE(gbo)->tp_free(gbo);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -714,7 +714,7 @@ cycle_dealloc(cycleobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->saved);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -857,7 +857,7 @@ dropwhile_dealloc(dropwhileobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -877,7 +877,7 @@ dropwhile_next(dropwhileobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
iternext = *Py_TYPE(it)->tp_iternext;
|
||||
for (;;) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -1000,7 +1000,7 @@ takewhile_dealloc(takewhileobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1022,7 +1022,7 @@ takewhile_next(takewhileobject *lz)
|
|||
return NULL;
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
item = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (item == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ islice_dealloc(isliceobject *lz)
|
|||
{
|
||||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1209,7 +1209,7 @@ islice_next(isliceobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
iternext = *Py_TYPE(it)->tp_iternext;
|
||||
while (lz->cnt < lz->next) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -1333,7 +1333,7 @@ starmap_dealloc(starmapobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1352,7 +1352,7 @@ starmap_next(starmapobject *lz)
|
|||
PyObject *it = lz->it;
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
args = (*Py_Type(it)->tp_iternext)(it);
|
||||
args = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (args == NULL)
|
||||
return NULL;
|
||||
if (!PyTuple_CheckExact(args)) {
|
||||
|
@ -1478,7 +1478,7 @@ imap_dealloc(imapobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->iters);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1656,7 +1656,7 @@ chain_dealloc(chainobject *lz)
|
|||
{
|
||||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->ittuple);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1787,7 +1787,7 @@ ifilter_dealloc(ifilterobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1807,7 +1807,7 @@ ifilter_next(ifilterobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
iternext = *Py_TYPE(it)->tp_iternext;
|
||||
for (;;) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -1931,7 +1931,7 @@ ifilterfalse_dealloc(ifilterfalseobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1951,7 +1951,7 @@ ifilterfalse_next(ifilterfalseobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
iternext = *Py_TYPE(it)->tp_iternext;
|
||||
for (;;) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -2261,7 +2261,7 @@ izip_dealloc(izipobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->ittuple);
|
||||
Py_XDECREF(lz->result);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2284,12 +2284,12 @@ izip_next(izipobject *lz)
|
|||
|
||||
if (tuplesize == 0)
|
||||
return NULL;
|
||||
if (Py_Refcnt(result) == 1) {
|
||||
if (Py_REFCNT(result) == 1) {
|
||||
Py_INCREF(result);
|
||||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
assert(PyIter_Check(it));
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
item = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
|
@ -2305,7 +2305,7 @@ izip_next(izipobject *lz)
|
|||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
assert(PyIter_Check(it));
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
item = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
|
@ -2411,7 +2411,7 @@ repeat_dealloc(repeatobject *ro)
|
|||
{
|
||||
PyObject_GC_UnTrack(ro);
|
||||
Py_XDECREF(ro->element);
|
||||
Py_Type(ro)->tp_free(ro);
|
||||
Py_TYPE(ro)->tp_free(ro);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2606,7 +2606,7 @@ izip_longest_dealloc(iziplongestobject *lz)
|
|||
Py_XDECREF(lz->ittuple);
|
||||
Py_XDECREF(lz->result);
|
||||
Py_XDECREF(lz->fillvalue);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
Py_TYPE(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2632,7 +2632,7 @@ izip_longest_next(iziplongestobject *lz)
|
|||
return NULL;
|
||||
if (lz->numactive == 0)
|
||||
return NULL;
|
||||
if (Py_Refcnt(result) == 1) {
|
||||
if (Py_REFCNT(result) == 1) {
|
||||
Py_INCREF(result);
|
||||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
|
@ -2641,7 +2641,7 @@ izip_longest_next(iziplongestobject *lz)
|
|||
item = lz->fillvalue;
|
||||
} else {
|
||||
assert(PyIter_Check(it));
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
item = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
lz->numactive -= 1;
|
||||
if (lz->numactive == 0) {
|
||||
|
@ -2670,7 +2670,7 @@ izip_longest_next(iziplongestobject *lz)
|
|||
item = lz->fillvalue;
|
||||
} else {
|
||||
assert(PyIter_Check(it));
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
item = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
lz->numactive -= 1;
|
||||
if (lz->numactive == 0) {
|
||||
|
@ -2801,7 +2801,7 @@ inititertools(void)
|
|||
NULL
|
||||
};
|
||||
|
||||
Py_Type(&teedataobject_type) = &PyType_Type;
|
||||
Py_TYPE(&teedataobject_type) = &PyType_Type;
|
||||
m = Py_InitModule3("itertools", module_methods, module_doc);
|
||||
if (m == NULL)
|
||||
return;
|
||||
|
|
|
@ -298,7 +298,7 @@ init_md5(void)
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
Py_Type(&MD5type) = &PyType_Type;
|
||||
Py_TYPE(&MD5type) = &PyType_Type;
|
||||
if (PyType_Ready(&MD5type) < 0)
|
||||
return;
|
||||
m = Py_InitModule3("_md5", md5_functions, module_doc);
|
||||
|
|
|
@ -1329,7 +1329,7 @@ PyMODINIT_FUNC
|
|||
PyObject *dict, *module;
|
||||
|
||||
/* Patch the object type */
|
||||
Py_Type(&mmap_object_type) = &PyType_Type;
|
||||
Py_TYPE(&mmap_object_type) = &PyType_Type;
|
||||
|
||||
module = Py_InitModule("mmap", mmap_functions);
|
||||
if (module == NULL)
|
||||
|
|
|
@ -693,7 +693,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
|||
PyErr_Format(parser_error,
|
||||
"second item in terminal node must be a string,"
|
||||
" found %s",
|
||||
Py_Type(temp)->tp_name);
|
||||
Py_TYPE(temp)->tp_name);
|
||||
Py_DECREF(temp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
|||
PyErr_Format(parser_error,
|
||||
"third item in terminal node must be an"
|
||||
" integer, found %s",
|
||||
Py_Type(temp)->tp_name);
|
||||
Py_TYPE(temp)->tp_name);
|
||||
Py_DECREF(o);
|
||||
Py_DECREF(temp);
|
||||
return 0;
|
||||
|
@ -3232,7 +3232,7 @@ initparser(void)
|
|||
{
|
||||
PyObject *module, *copyreg;
|
||||
|
||||
Py_Type(&PyST_Type) = &PyType_Type;
|
||||
Py_TYPE(&PyST_Type) = &PyType_Type;
|
||||
module = Py_InitModule("parser", parser_functions);
|
||||
if (module == NULL)
|
||||
return;
|
||||
|
|
|
@ -2670,7 +2670,7 @@ extract_time(PyObject *t, long* sec, long* usec)
|
|||
long intval;
|
||||
if (PyFloat_Check(t)) {
|
||||
double tval = PyFloat_AsDouble(t);
|
||||
PyObject *intobj = Py_Type(t)->tp_as_number->nb_int(t);
|
||||
PyObject *intobj = Py_TYPE(t)->tp_as_number->nb_int(t);
|
||||
if (!intobj)
|
||||
return -1;
|
||||
intval = PyInt_AsLong(intobj);
|
||||
|
|
|
@ -974,7 +974,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
|
|||
if (!PyString_Check(str)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"read() did not return a string object (type=%.400s)",
|
||||
Py_Type(str)->tp_name);
|
||||
Py_TYPE(str)->tp_name);
|
||||
goto finally;
|
||||
}
|
||||
len = PyString_GET_SIZE(str);
|
||||
|
@ -1859,7 +1859,7 @@ MODULE_INITFUNC(void)
|
|||
if (modelmod_name == NULL)
|
||||
return;
|
||||
|
||||
Py_Type(&Xmlparsetype) = &PyType_Type;
|
||||
Py_TYPE(&Xmlparsetype) = &PyType_Type;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule3(MODULE_NAME, pyexpat_methods,
|
||||
|
|
|
@ -705,7 +705,7 @@ initselect(void)
|
|||
#else
|
||||
{
|
||||
#endif
|
||||
Py_Type(&poll_Type) = &PyType_Type;
|
||||
Py_TYPE(&poll_Type) = &PyType_Type;
|
||||
PyModule_AddIntConstant(m, "POLLIN", POLLIN);
|
||||
PyModule_AddIntConstant(m, "POLLPRI", POLLPRI);
|
||||
PyModule_AddIntConstant(m, "POLLOUT", POLLOUT);
|
||||
|
|
|
@ -409,7 +409,7 @@ SHA256_copy(SHAobject *self, PyObject *unused)
|
|||
{
|
||||
SHAobject *newobj;
|
||||
|
||||
if (Py_Type(self) == &SHA256type) {
|
||||
if (Py_TYPE(self) == &SHA256type) {
|
||||
if ( (newobj = newSHA256object())==NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -687,10 +687,10 @@ init_sha256(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
Py_Type(&SHA224type) = &PyType_Type;
|
||||
Py_TYPE(&SHA224type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA224type) < 0)
|
||||
return;
|
||||
Py_Type(&SHA256type) = &PyType_Type;
|
||||
Py_TYPE(&SHA256type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA256type) < 0)
|
||||
return;
|
||||
m = Py_InitModule("_sha256", SHA_functions);
|
||||
|
|
|
@ -753,10 +753,10 @@ init_sha512(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
Py_Type(&SHA384type) = &PyType_Type;
|
||||
Py_TYPE(&SHA384type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA384type) < 0)
|
||||
return;
|
||||
Py_Type(&SHA512type) = &PyType_Type;
|
||||
Py_TYPE(&SHA512type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA512type) < 0)
|
||||
return;
|
||||
m = Py_InitModule("_sha512", SHA_functions);
|
||||
|
|
|
@ -576,7 +576,7 @@ init_sha(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
Py_Type(&SHAtype) = &PyType_Type;
|
||||
Py_TYPE(&SHAtype) = &PyType_Type;
|
||||
if (PyType_Ready(&SHAtype) < 0)
|
||||
return;
|
||||
m = Py_InitModule("_sha", SHA_functions);
|
||||
|
|
|
@ -1171,7 +1171,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_NETLINK address must be tuple, not %.500s",
|
||||
Py_Type(args)->tp_name);
|
||||
Py_TYPE(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &pid, &groups))
|
||||
|
@ -1194,7 +1194,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_INET address must be tuple, not %.500s",
|
||||
Py_Type(args)->tp_name);
|
||||
Py_TYPE(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "eti:getsockaddrarg",
|
||||
|
@ -1224,7 +1224,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_INET6 address must be tuple, not %.500s",
|
||||
Py_Type(args)->tp_name);
|
||||
Py_TYPE(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "eti|ii",
|
||||
|
@ -1346,7 +1346,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_PACKET address must be tuple, not %.500s",
|
||||
Py_Type(args)->tp_name);
|
||||
Py_TYPE(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName,
|
||||
|
@ -2769,7 +2769,7 @@ sock_dealloc(PySocketSockObject *s)
|
|||
{
|
||||
if (s->sock_fd != -1)
|
||||
(void) SOCKETCLOSE(s->sock_fd);
|
||||
Py_Type(s)->tp_free((PyObject *)s);
|
||||
Py_TYPE(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3480,7 +3480,7 @@ socket_ntohl(PyObject *self, PyObject *arg)
|
|||
else
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"expected int/long, %s found",
|
||||
Py_Type(arg)->tp_name);
|
||||
Py_TYPE(arg)->tp_name);
|
||||
if (x == (unsigned long) -1 && PyErr_Occurred())
|
||||
return NULL;
|
||||
return PyLong_FromUnsignedLong(ntohl(x));
|
||||
|
@ -3549,7 +3549,7 @@ socket_htonl(PyObject *self, PyObject *arg)
|
|||
else
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"expected int/long, %s found",
|
||||
Py_Type(arg)->tp_name);
|
||||
Py_TYPE(arg)->tp_name);
|
||||
return PyLong_FromUnsignedLong(htonl((unsigned long)x));
|
||||
}
|
||||
|
||||
|
@ -4199,7 +4199,7 @@ init_socket(void)
|
|||
if (!os_init())
|
||||
return;
|
||||
|
||||
Py_Type(&sock_type) = &PyType_Type;
|
||||
Py_TYPE(&sock_type) = &PyType_Type;
|
||||
m = Py_InitModule3(PySocket_MODULE_NAME,
|
||||
socket_methods,
|
||||
socket_doc);
|
||||
|
|
|
@ -42,8 +42,8 @@ static sadstatusobject *sads_alloc(void); /* Forward */
|
|||
|
||||
static PyObject *SunAudioError;
|
||||
|
||||
#define is_sadobject(v) (Py_Type(v) == &Sadtype)
|
||||
#define is_sadstatusobject(v) (Py_Type(v) == &Sadstatustype)
|
||||
#define is_sadobject(v) (Py_TYPE(v) == &Sadtype)
|
||||
#define is_sadstatusobject(v) (Py_TYPE(v) == &Sadstatustype)
|
||||
|
||||
|
||||
static sadobject *
|
||||
|
|
|
@ -250,7 +250,7 @@ local_dealloc(localobject *self)
|
|||
}
|
||||
|
||||
local_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -282,8 +282,8 @@ _ldict(localobject *self)
|
|||
Py_INCREF(ldict);
|
||||
self->dict = ldict; /* still borrowed */
|
||||
|
||||
if (Py_Type(self)->tp_init != PyBaseObject_Type.tp_init &&
|
||||
Py_Type(self)->tp_init((PyObject*)self,
|
||||
if (Py_TYPE(self)->tp_init != PyBaseObject_Type.tp_init &&
|
||||
Py_TYPE(self)->tp_init((PyObject*)self,
|
||||
self->args, self->kw) < 0) {
|
||||
/* we need to get rid of ldict from thread so
|
||||
we create a new one the next time we do an attr
|
||||
|
@ -386,7 +386,7 @@ local_getattro(localobject *self, PyObject *name)
|
|||
if (ldict == NULL)
|
||||
return NULL;
|
||||
|
||||
if (Py_Type(self) != &localtype)
|
||||
if (Py_TYPE(self) != &localtype)
|
||||
/* use generic lookup for subtypes */
|
||||
return PyObject_GenericGetAttr((PyObject *)self, name);
|
||||
|
||||
|
|
|
@ -1187,7 +1187,7 @@ initunicodedata(void)
|
|||
{
|
||||
PyObject *m, *v;
|
||||
|
||||
Py_Type(&UCD_Type) = &PyType_Type;
|
||||
Py_TYPE(&UCD_Type) = &PyType_Type;
|
||||
|
||||
m = Py_InitModule3(
|
||||
"unicodedata", unicodedata_functions, unicodedata_docstring);
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Xxo_Type;
|
||||
|
||||
#define XxoObject_Check(v) (Py_Type(v) == &Xxo_Type)
|
||||
#define XxoObject_Check(v) (Py_TYPE(v) == &Xxo_Type)
|
||||
|
||||
static XxoObject *
|
||||
newXxoObject(PyObject *arg)
|
||||
|
|
|
@ -181,7 +181,7 @@ zipimporter_dealloc(ZipImporter *self)
|
|||
Py_XDECREF(self->archive);
|
||||
Py_XDECREF(self->prefix);
|
||||
Py_XDECREF(self->files);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
@ -986,8 +986,8 @@ PyMODINIT_FUNC
|
|||
PyInit_zlib(void)
|
||||
{
|
||||
PyObject *m, *ver;
|
||||
Py_Type(&Comptype) = &PyType_Type;
|
||||
Py_Type(&Decomptype) = &PyType_Type;
|
||||
Py_TYPE(&Comptype) = &PyType_Type;
|
||||
Py_TYPE(&Decomptype) = &PyType_Type;
|
||||
m = Py_InitModule4("zlib", zlib_methods,
|
||||
zlib_module_documentation,
|
||||
(PyObject*)NULL,PYTHON_API_VERSION);
|
||||
|
|
|
@ -202,7 +202,7 @@ PyDict_New(void)
|
|||
if (num_free_dicts) {
|
||||
mp = free_dicts[--num_free_dicts];
|
||||
assert (mp != NULL);
|
||||
assert (Py_Type(mp) == &PyDict_Type);
|
||||
assert (Py_TYPE(mp) == &PyDict_Type);
|
||||
_Py_NewReference((PyObject *)mp);
|
||||
if (mp->ma_fill) {
|
||||
EMPTY_TO_MINSIZE(mp);
|
||||
|
@ -868,10 +868,10 @@ dict_dealloc(register PyDictObject *mp)
|
|||
}
|
||||
if (mp->ma_table != mp->ma_smalltable)
|
||||
PyMem_DEL(mp->ma_table);
|
||||
if (num_free_dicts < MAXFREEDICTS && Py_Type(mp) == &PyDict_Type)
|
||||
if (num_free_dicts < MAXFREEDICTS && Py_TYPE(mp) == &PyDict_Type)
|
||||
free_dicts[num_free_dicts++] = mp;
|
||||
else
|
||||
Py_Type(mp)->tp_free((PyObject *)mp);
|
||||
Py_TYPE(mp)->tp_free((PyObject *)mp);
|
||||
Py_TRASHCAN_SAFE_END(mp)
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
|
|||
if (missing_str == NULL)
|
||||
missing_str =
|
||||
PyString_InternFromString("__missing__");
|
||||
missing = _PyType_Lookup(Py_Type(mp), missing_str);
|
||||
missing = _PyType_Lookup(Py_TYPE(mp), missing_str);
|
||||
if (missing != NULL)
|
||||
return PyObject_CallFunctionObjArgs(missing,
|
||||
(PyObject *)mp, key, NULL);
|
||||
|
|
|
@ -46,7 +46,7 @@ enum_dealloc(enumobject *en)
|
|||
Py_XDECREF(en->en_sit);
|
||||
Py_XDECREF(en->en_result);
|
||||
Py_XDECREF(en->en_longindex);
|
||||
Py_Type(en)->tp_free(en);
|
||||
Py_TYPE(en)->tp_free(en);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -108,7 +108,7 @@ enum_next(enumobject *en)
|
|||
PyObject *result = en->en_result;
|
||||
PyObject *it = en->en_sit;
|
||||
|
||||
next_item = (*Py_Type(it)->tp_iternext)(it);
|
||||
next_item = (*Py_TYPE(it)->tp_iternext)(it);
|
||||
if (next_item == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -237,7 +237,7 @@ reversed_dealloc(reversedobject *ro)
|
|||
{
|
||||
PyObject_GC_UnTrack(ro);
|
||||
Py_XDECREF(ro->seq);
|
||||
Py_Type(ro)->tp_free(ro);
|
||||
Py_TYPE(ro)->tp_free(ro);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -56,7 +56,7 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
static int
|
||||
BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if (!_PyArg_NoKeywords(Py_Type(self)->tp_name, kwds))
|
||||
if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
|
||||
return -1;
|
||||
|
||||
Py_DECREF(self->args);
|
||||
|
@ -85,7 +85,7 @@ BaseException_dealloc(PyBaseExceptionObject *self)
|
|||
{
|
||||
_PyObject_GC_UNTRACK(self);
|
||||
BaseException_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -129,7 +129,7 @@ BaseException_repr(PyBaseExceptionObject *self)
|
|||
if (!repr_suffix)
|
||||
return NULL;
|
||||
|
||||
name = (char *)Py_Type(self)->tp_name;
|
||||
name = (char *)Py_TYPE(self)->tp_name;
|
||||
dot = strrchr(name, '.');
|
||||
if (dot != NULL) name = dot+1;
|
||||
|
||||
|
@ -148,9 +148,9 @@ static PyObject *
|
|||
BaseException_reduce(PyBaseExceptionObject *self)
|
||||
{
|
||||
if (self->args && self->dict)
|
||||
return PyTuple_Pack(3, Py_Type(self), self->args, self->dict);
|
||||
return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict);
|
||||
else
|
||||
return PyTuple_Pack(2, Py_Type(self), self->args);
|
||||
return PyTuple_Pack(2, Py_TYPE(self), self->args);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -478,7 +478,7 @@ SystemExit_dealloc(PySystemExitObject *self)
|
|||
{
|
||||
_PyObject_GC_UNTRACK(self);
|
||||
SystemExit_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -583,7 +583,7 @@ EnvironmentError_dealloc(PyEnvironmentErrorObject *self)
|
|||
{
|
||||
_PyObject_GC_UNTRACK(self);
|
||||
EnvironmentError_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -725,9 +725,9 @@ EnvironmentError_reduce(PyEnvironmentErrorObject *self)
|
|||
Py_INCREF(args);
|
||||
|
||||
if (self->dict)
|
||||
res = PyTuple_Pack(3, Py_Type(self), args, self->dict);
|
||||
res = PyTuple_Pack(3, Py_TYPE(self), args, self->dict);
|
||||
else
|
||||
res = PyTuple_Pack(2, Py_Type(self), args);
|
||||
res = PyTuple_Pack(2, Py_TYPE(self), args);
|
||||
Py_DECREF(args);
|
||||
return res;
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ WindowsError_dealloc(PyWindowsErrorObject *self)
|
|||
{
|
||||
_PyObject_GC_UNTRACK(self);
|
||||
WindowsError_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1054,7 +1054,7 @@ SyntaxError_dealloc(PySyntaxErrorObject *self)
|
|||
{
|
||||
_PyObject_GC_UNTRACK(self);
|
||||
SyntaxError_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1532,7 +1532,7 @@ UnicodeError_dealloc(PyUnicodeErrorObject *self)
|
|||
{
|
||||
_PyObject_GC_UNTRACK(self);
|
||||
UnicodeError_clear(self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -406,7 +406,7 @@ file_dealloc(PyFileObject *f)
|
|||
Py_XDECREF(f->f_mode);
|
||||
Py_XDECREF(f->f_encoding);
|
||||
drop_readahead(f);
|
||||
Py_Type(f)->tp_free((PyObject *)f);
|
||||
Py_TYPE(f)->tp_free((PyObject *)f);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
@ -42,8 +42,8 @@ fill_free_list(void)
|
|||
p = &((PyFloatBlock *)p)->objects[0];
|
||||
q = p + N_FLOATOBJECTS;
|
||||
while (--q > p)
|
||||
Py_Type(q) = (struct _typeobject *)(q-1);
|
||||
Py_Type(q) = NULL;
|
||||
Py_TYPE(q) = (struct _typeobject *)(q-1);
|
||||
Py_TYPE(q) = NULL;
|
||||
return p + N_FLOATOBJECTS - 1;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ PyFloat_FromDouble(double fval)
|
|||
}
|
||||
/* Inline PyObject_New */
|
||||
op = free_list;
|
||||
free_list = (PyFloatObject *)Py_Type(op);
|
||||
free_list = (PyFloatObject *)Py_TYPE(op);
|
||||
PyObject_INIT(op, &PyFloat_Type);
|
||||
op->ob_fval = fval;
|
||||
return (PyObject *) op;
|
||||
|
@ -242,11 +242,11 @@ static void
|
|||
float_dealloc(PyFloatObject *op)
|
||||
{
|
||||
if (PyFloat_CheckExact(op)) {
|
||||
Py_Type(op) = (struct _typeobject *)free_list;
|
||||
Py_TYPE(op) = (struct _typeobject *)free_list;
|
||||
free_list = op;
|
||||
}
|
||||
else
|
||||
Py_Type(op)->tp_free((PyObject *)op);
|
||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -264,7 +264,7 @@ PyFloat_AsDouble(PyObject *op)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((nb = Py_Type(op)->tp_as_number) == NULL || nb->nb_float == NULL) {
|
||||
if ((nb = Py_TYPE(op)->tp_as_number) == NULL || nb->nb_float == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "a float is required");
|
||||
return -1;
|
||||
}
|
||||
|
@ -1193,7 +1193,7 @@ float_getformat(PyTypeObject *v, PyObject* arg)
|
|||
if (!PyString_Check(arg)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__getformat__() argument must be string, not %.500s",
|
||||
Py_Type(arg)->tp_name);
|
||||
Py_TYPE(arg)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
s = PyString_AS_STRING(arg);
|
||||
|
@ -1476,7 +1476,7 @@ PyFloat_Fini(void)
|
|||
for (i = 0, p = &list->objects[0];
|
||||
i < N_FLOATOBJECTS;
|
||||
i++, p++) {
|
||||
if (PyFloat_CheckExact(p) && Py_Refcnt(p) != 0)
|
||||
if (PyFloat_CheckExact(p) && Py_REFCNT(p) != 0)
|
||||
frem++;
|
||||
}
|
||||
next = list->next;
|
||||
|
@ -1487,8 +1487,8 @@ PyFloat_Fini(void)
|
|||
i < N_FLOATOBJECTS;
|
||||
i++, p++) {
|
||||
if (!PyFloat_CheckExact(p) ||
|
||||
Py_Refcnt(p) == 0) {
|
||||
Py_Type(p) = (struct _typeobject *)
|
||||
Py_REFCNT(p) == 0) {
|
||||
Py_TYPE(p) = (struct _typeobject *)
|
||||
free_list;
|
||||
free_list = p;
|
||||
}
|
||||
|
@ -1520,7 +1520,7 @@ PyFloat_Fini(void)
|
|||
i < N_FLOATOBJECTS;
|
||||
i++, p++) {
|
||||
if (PyFloat_CheckExact(p) &&
|
||||
Py_Refcnt(p) != 0) {
|
||||
Py_REFCNT(p) != 0) {
|
||||
char buf[100];
|
||||
PyFloat_AsString(buf, p);
|
||||
/* XXX(twouters) cast refcount to
|
||||
|
@ -1529,7 +1529,7 @@ PyFloat_Fini(void)
|
|||
*/
|
||||
fprintf(stderr,
|
||||
"# <float at %p, refcnt=%ld, val=%s>\n",
|
||||
p, (long)Py_Refcnt(p), buf);
|
||||
p, (long)Py_REFCNT(p), buf);
|
||||
}
|
||||
}
|
||||
list = list->next;
|
||||
|
|
|
@ -622,7 +622,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,
|
|||
--numfree;
|
||||
f = free_list;
|
||||
free_list = free_list->f_back;
|
||||
if (Py_Size(f) < extras) {
|
||||
if (Py_SIZE(f) < extras) {
|
||||
f = PyObject_GC_Resize(PyFrameObject, f, extras);
|
||||
if (f == NULL) {
|
||||
Py_DECREF(builtins);
|
||||
|
|
|
@ -614,7 +614,7 @@ cm_dealloc(classmethod *cm)
|
|||
{
|
||||
_PyObject_GC_UNTRACK((PyObject *)cm);
|
||||
Py_XDECREF(cm->cm_callable);
|
||||
Py_Type(cm)->tp_free((PyObject *)cm);
|
||||
Py_TYPE(cm)->tp_free((PyObject *)cm);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -643,9 +643,9 @@ cm_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
|||
return NULL;
|
||||
}
|
||||
if (type == NULL)
|
||||
type = (PyObject *)(Py_Type(obj));
|
||||
type = (PyObject *)(Py_TYPE(obj));
|
||||
return PyMethod_New(cm->cm_callable,
|
||||
type, (PyObject *)(Py_Type(type)));
|
||||
type, (PyObject *)(Py_TYPE(type)));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -771,7 +771,7 @@ sm_dealloc(staticmethod *sm)
|
|||
{
|
||||
_PyObject_GC_UNTRACK((PyObject *)sm);
|
||||
Py_XDECREF(sm->sm_callable);
|
||||
Py_Type(sm)->tp_free((PyObject *)sm);
|
||||
Py_TYPE(sm)->tp_free((PyObject *)sm);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -28,7 +28,7 @@ gen_dealloc(PyGenObject *gen)
|
|||
|
||||
if (gen->gi_frame != NULL && gen->gi_frame->f_stacktop != NULL) {
|
||||
/* Generator is paused, so we need to close */
|
||||
Py_Type(gen)->tp_del(self);
|
||||
Py_TYPE(gen)->tp_del(self);
|
||||
if (self->ob_refcnt > 0)
|
||||
return; /* resurrected. :( */
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ fill_free_list(void)
|
|||
p = &((PyIntBlock *)p)->objects[0];
|
||||
q = p + N_INTOBJECTS;
|
||||
while (--q > p)
|
||||
Py_Type(q) = (struct _typeobject *)(q-1);
|
||||
Py_Type(q) = NULL;
|
||||
Py_TYPE(q) = (struct _typeobject *)(q-1);
|
||||
Py_TYPE(q) = NULL;
|
||||
return p + N_INTOBJECTS - 1;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ PyInt_FromLong(long ival)
|
|||
}
|
||||
/* Inline PyObject_New */
|
||||
v = free_list;
|
||||
free_list = (PyIntObject *)Py_Type(v);
|
||||
free_list = (PyIntObject *)Py_TYPE(v);
|
||||
PyObject_INIT(v, &PyInt_Type);
|
||||
v->ob_ival = ival;
|
||||
return (PyObject *) v;
|
||||
|
@ -128,17 +128,17 @@ static void
|
|||
int_dealloc(PyIntObject *v)
|
||||
{
|
||||
if (PyInt_CheckExact(v)) {
|
||||
Py_Type(v) = (struct _typeobject *)free_list;
|
||||
Py_TYPE(v) = (struct _typeobject *)free_list;
|
||||
free_list = v;
|
||||
}
|
||||
else
|
||||
Py_Type(v)->tp_free((PyObject *)v);
|
||||
Py_TYPE(v)->tp_free((PyObject *)v);
|
||||
}
|
||||
|
||||
static void
|
||||
int_free(PyIntObject *v)
|
||||
{
|
||||
Py_Type(v) = (struct _typeobject *)free_list;
|
||||
Py_TYPE(v) = (struct _typeobject *)free_list;
|
||||
free_list = v;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ PyInt_AsLong(register PyObject *op)
|
|||
if (op && PyInt_Check(op))
|
||||
return PyInt_AS_LONG((PyIntObject*) op);
|
||||
|
||||
if (op == NULL || (nb = Py_Type(op)->tp_as_number) == NULL ||
|
||||
if (op == NULL || (nb = Py_TYPE(op)->tp_as_number) == NULL ||
|
||||
nb->nb_int == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return -1;
|
||||
|
@ -207,7 +207,7 @@ PyInt_AsSsize_t(register PyObject *op)
|
|||
return PyInt_AsLong(op);
|
||||
#else
|
||||
|
||||
if ((nb = Py_Type(op)->tp_as_number) == NULL ||
|
||||
if ((nb = Py_TYPE(op)->tp_as_number) == NULL ||
|
||||
(nb->nb_int == NULL && nb->nb_long == 0)) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return -1;
|
||||
|
@ -256,7 +256,7 @@ PyInt_AsUnsignedLongMask(register PyObject *op)
|
|||
if (op && PyLong_Check(op))
|
||||
return PyLong_AsUnsignedLongMask(op);
|
||||
|
||||
if (op == NULL || (nb = Py_Type(op)->tp_as_number) == NULL ||
|
||||
if (op == NULL || (nb = Py_TYPE(op)->tp_as_number) == NULL ||
|
||||
nb->nb_int == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return (unsigned long)-1;
|
||||
|
@ -301,7 +301,7 @@ PyInt_AsUnsignedLongLongMask(register PyObject *op)
|
|||
if (op && PyLong_Check(op))
|
||||
return PyLong_AsUnsignedLongLongMask(op);
|
||||
|
||||
if (op == NULL || (nb = Py_Type(op)->tp_as_number) == NULL ||
|
||||
if (op == NULL || (nb = Py_TYPE(op)->tp_as_number) == NULL ||
|
||||
nb->nb_int == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError, "an integer is required");
|
||||
return (unsigned PY_LONG_LONG)-1;
|
||||
|
@ -1172,7 +1172,7 @@ _PyInt_Init(void)
|
|||
return 0;
|
||||
/* PyObject_New is inlined */
|
||||
v = free_list;
|
||||
free_list = (PyIntObject *)Py_Type(v);
|
||||
free_list = (PyIntObject *)Py_TYPE(v);
|
||||
PyObject_INIT(v, &PyInt_Type);
|
||||
v->ob_ival = ival;
|
||||
small_ints[ival + NSMALLNEGINTS] = v;
|
||||
|
@ -1225,7 +1225,7 @@ PyInt_Fini(void)
|
|||
ctr++, p++) {
|
||||
if (!PyInt_CheckExact(p) ||
|
||||
p->ob_refcnt == 0) {
|
||||
Py_Type(p) = (struct _typeobject *)
|
||||
Py_TYPE(p) = (struct _typeobject *)
|
||||
free_list;
|
||||
free_list = p;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
|
|||
*/
|
||||
if (allocated >= newsize && newsize >= (allocated >> 1)) {
|
||||
assert(self->ob_item != NULL || newsize == 0);
|
||||
Py_Size(self) = newsize;
|
||||
Py_SIZE(self) = newsize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ list_resize(PyListObject *self, Py_ssize_t newsize)
|
|||
return -1;
|
||||
}
|
||||
self->ob_item = items;
|
||||
Py_Size(self) = newsize;
|
||||
Py_SIZE(self) = newsize;
|
||||
self->allocated = new_allocated;
|
||||
return 0;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ PyList_New(Py_ssize_t size)
|
|||
}
|
||||
memset(op->ob_item, 0, nbytes);
|
||||
}
|
||||
Py_Size(op) = size;
|
||||
Py_SIZE(op) = size;
|
||||
op->allocated = size;
|
||||
_PyObject_GC_TRACK(op);
|
||||
return (PyObject *) op;
|
||||
|
@ -128,7 +128,7 @@ PyList_Size(PyObject *op)
|
|||
return -1;
|
||||
}
|
||||
else
|
||||
return Py_Size(op);
|
||||
return Py_SIZE(op);
|
||||
}
|
||||
|
||||
static PyObject *indexerr = NULL;
|
||||
|
@ -140,7 +140,7 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
|
|||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
if (i < 0 || i >= Py_Size(op)) {
|
||||
if (i < 0 || i >= Py_SIZE(op)) {
|
||||
if (indexerr == NULL)
|
||||
indexerr = PyString_FromString(
|
||||
"list index out of range");
|
||||
|
@ -161,7 +161,7 @@ PyList_SetItem(register PyObject *op, register Py_ssize_t i,
|
|||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
if (i < 0 || i >= Py_Size(op)) {
|
||||
if (i < 0 || i >= Py_SIZE(op)) {
|
||||
Py_XDECREF(newitem);
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"list assignment index out of range");
|
||||
|
@ -177,7 +177,7 @@ PyList_SetItem(register PyObject *op, register Py_ssize_t i,
|
|||
static int
|
||||
ins1(PyListObject *self, Py_ssize_t where, PyObject *v)
|
||||
{
|
||||
Py_ssize_t i, n = Py_Size(self);
|
||||
Py_ssize_t i, n = Py_SIZE(self);
|
||||
PyObject **items;
|
||||
if (v == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
|
@ -259,7 +259,7 @@ list_dealloc(PyListObject *op)
|
|||
There's a simple test case where somehow this reduces
|
||||
thrashing when a *very* large list is created and
|
||||
immediately deleted. */
|
||||
i = Py_Size(op);
|
||||
i = Py_SIZE(op);
|
||||
while (--i >= 0) {
|
||||
Py_XDECREF(op->ob_item[i]);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ list_dealloc(PyListObject *op)
|
|||
if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op))
|
||||
free_lists[num_free_lists++] = op;
|
||||
else
|
||||
Py_Type(op)->tp_free((PyObject *)op);
|
||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||
Py_TRASHCAN_SAFE_END(op)
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ list_print(PyListObject *op, FILE *fp, int flags)
|
|||
Py_BEGIN_ALLOW_THREADS
|
||||
fprintf(fp, "[");
|
||||
Py_END_ALLOW_THREADS
|
||||
for (i = 0; i < Py_Size(op); i++) {
|
||||
for (i = 0; i < Py_SIZE(op); i++) {
|
||||
if (i > 0) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
fprintf(fp, ", ");
|
||||
|
@ -320,7 +320,7 @@ list_repr(PyListObject *v)
|
|||
return i > 0 ? PyString_FromString("[...]") : NULL;
|
||||
}
|
||||
|
||||
if (Py_Size(v) == 0) {
|
||||
if (Py_SIZE(v) == 0) {
|
||||
result = PyString_FromString("[]");
|
||||
goto Done;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ list_repr(PyListObject *v)
|
|||
|
||||
/* Do repr() on each element. Note that this may mutate the list,
|
||||
so must refetch the list size on each iteration. */
|
||||
for (i = 0; i < Py_Size(v); ++i) {
|
||||
for (i = 0; i < Py_SIZE(v); ++i) {
|
||||
int status;
|
||||
if (Py_EnterRecursiveCall(" while getting the repr of a list"))
|
||||
goto Done;
|
||||
|
@ -381,7 +381,7 @@ Done:
|
|||
static Py_ssize_t
|
||||
list_length(PyListObject *a)
|
||||
{
|
||||
return Py_Size(a);
|
||||
return Py_SIZE(a);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -390,7 +390,7 @@ list_contains(PyListObject *a, PyObject *el)
|
|||
Py_ssize_t i;
|
||||
int cmp;
|
||||
|
||||
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(a); ++i)
|
||||
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i)
|
||||
cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i),
|
||||
Py_EQ);
|
||||
return cmp;
|
||||
|
@ -399,7 +399,7 @@ list_contains(PyListObject *a, PyObject *el)
|
|||
static PyObject *
|
||||
list_item(PyListObject *a, Py_ssize_t i)
|
||||
{
|
||||
if (i < 0 || i >= Py_Size(a)) {
|
||||
if (i < 0 || i >= Py_SIZE(a)) {
|
||||
if (indexerr == NULL)
|
||||
indexerr = PyString_FromString(
|
||||
"list index out of range");
|
||||
|
@ -418,12 +418,12 @@ list_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
|
|||
Py_ssize_t i, len;
|
||||
if (ilow < 0)
|
||||
ilow = 0;
|
||||
else if (ilow > Py_Size(a))
|
||||
ilow = Py_Size(a);
|
||||
else if (ilow > Py_SIZE(a))
|
||||
ilow = Py_SIZE(a);
|
||||
if (ihigh < ilow)
|
||||
ihigh = ilow;
|
||||
else if (ihigh > Py_Size(a))
|
||||
ihigh = Py_Size(a);
|
||||
else if (ihigh > Py_SIZE(a))
|
||||
ihigh = Py_SIZE(a);
|
||||
len = ihigh - ilow;
|
||||
np = (PyListObject *) PyList_New(len);
|
||||
if (np == NULL)
|
||||
|
@ -463,7 +463,7 @@ list_concat(PyListObject *a, PyObject *bb)
|
|||
return NULL;
|
||||
}
|
||||
#define b ((PyListObject *)bb)
|
||||
size = Py_Size(a) + Py_Size(b);
|
||||
size = Py_SIZE(a) + Py_SIZE(b);
|
||||
if (size < 0)
|
||||
return PyErr_NoMemory();
|
||||
np = (PyListObject *) PyList_New(size);
|
||||
|
@ -472,14 +472,14 @@ list_concat(PyListObject *a, PyObject *bb)
|
|||
}
|
||||
src = a->ob_item;
|
||||
dest = np->ob_item;
|
||||
for (i = 0; i < Py_Size(a); i++) {
|
||||
for (i = 0; i < Py_SIZE(a); i++) {
|
||||
PyObject *v = src[i];
|
||||
Py_INCREF(v);
|
||||
dest[i] = v;
|
||||
}
|
||||
src = b->ob_item;
|
||||
dest = np->ob_item + Py_Size(a);
|
||||
for (i = 0; i < Py_Size(b); i++) {
|
||||
dest = np->ob_item + Py_SIZE(a);
|
||||
for (i = 0; i < Py_SIZE(b); i++) {
|
||||
PyObject *v = src[i];
|
||||
Py_INCREF(v);
|
||||
dest[i] = v;
|
||||
|
@ -498,8 +498,8 @@ list_repeat(PyListObject *a, Py_ssize_t n)
|
|||
PyObject *elem;
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
size = Py_Size(a) * n;
|
||||
if (n && size/n != Py_Size(a))
|
||||
size = Py_SIZE(a) * n;
|
||||
if (n && size/n != Py_SIZE(a))
|
||||
return PyErr_NoMemory();
|
||||
if (size == 0)
|
||||
return PyList_New(0);
|
||||
|
@ -508,7 +508,7 @@ list_repeat(PyListObject *a, Py_ssize_t n)
|
|||
return NULL;
|
||||
|
||||
items = np->ob_item;
|
||||
if (Py_Size(a) == 1) {
|
||||
if (Py_SIZE(a) == 1) {
|
||||
elem = a->ob_item[0];
|
||||
for (i = 0; i < n; i++) {
|
||||
items[i] = elem;
|
||||
|
@ -519,7 +519,7 @@ list_repeat(PyListObject *a, Py_ssize_t n)
|
|||
p = np->ob_item;
|
||||
items = a->ob_item;
|
||||
for (i = 0; i < n; i++) {
|
||||
for (j = 0; j < Py_Size(a); j++) {
|
||||
for (j = 0; j < Py_SIZE(a); j++) {
|
||||
*p = items[j];
|
||||
Py_INCREF(*p);
|
||||
p++;
|
||||
|
@ -536,8 +536,8 @@ list_clear(PyListObject *a)
|
|||
if (item != NULL) {
|
||||
/* Because XDECREF can recursively invoke operations on
|
||||
this list, we make it empty first. */
|
||||
i = Py_Size(a);
|
||||
Py_Size(a) = 0;
|
||||
i = Py_SIZE(a);
|
||||
Py_SIZE(a) = 0;
|
||||
a->ob_item = NULL;
|
||||
a->allocated = 0;
|
||||
while (--i >= 0) {
|
||||
|
@ -583,7 +583,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
else {
|
||||
if (a == b) {
|
||||
/* Special case "a[i:j] = a" -- copy b first */
|
||||
v = list_slice(b, 0, Py_Size(b));
|
||||
v = list_slice(b, 0, Py_SIZE(b));
|
||||
if (v == NULL)
|
||||
return result;
|
||||
result = list_ass_slice(a, ilow, ihigh, v);
|
||||
|
@ -598,18 +598,18 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
}
|
||||
if (ilow < 0)
|
||||
ilow = 0;
|
||||
else if (ilow > Py_Size(a))
|
||||
ilow = Py_Size(a);
|
||||
else if (ilow > Py_SIZE(a))
|
||||
ilow = Py_SIZE(a);
|
||||
|
||||
if (ihigh < ilow)
|
||||
ihigh = ilow;
|
||||
else if (ihigh > Py_Size(a))
|
||||
ihigh = Py_Size(a);
|
||||
else if (ihigh > Py_SIZE(a))
|
||||
ihigh = Py_SIZE(a);
|
||||
|
||||
norig = ihigh - ilow;
|
||||
assert(norig >= 0);
|
||||
d = n - norig;
|
||||
if (Py_Size(a) + d == 0) {
|
||||
if (Py_SIZE(a) + d == 0) {
|
||||
Py_XDECREF(v_as_SF);
|
||||
return list_clear(a);
|
||||
}
|
||||
|
@ -627,12 +627,12 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
|
||||
if (d < 0) { /* Delete -d items */
|
||||
memmove(&item[ihigh+d], &item[ihigh],
|
||||
(Py_Size(a) - ihigh)*sizeof(PyObject *));
|
||||
list_resize(a, Py_Size(a) + d);
|
||||
(Py_SIZE(a) - ihigh)*sizeof(PyObject *));
|
||||
list_resize(a, Py_SIZE(a) + d);
|
||||
item = a->ob_item;
|
||||
}
|
||||
else if (d > 0) { /* Insert d items */
|
||||
k = Py_Size(a);
|
||||
k = Py_SIZE(a);
|
||||
if (list_resize(a, k+d) < 0)
|
||||
goto Error;
|
||||
item = a->ob_item;
|
||||
|
@ -707,7 +707,7 @@ static int
|
|||
list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v)
|
||||
{
|
||||
PyObject *old_value;
|
||||
if (i < 0 || i >= Py_Size(a)) {
|
||||
if (i < 0 || i >= Py_SIZE(a)) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"list assignment index out of range");
|
||||
return -1;
|
||||
|
@ -766,7 +766,7 @@ listextend(PyListObject *self, PyObject *b)
|
|||
Py_DECREF(b);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
m = Py_Size(self);
|
||||
m = Py_SIZE(self);
|
||||
if (list_resize(self, m + n) == -1) {
|
||||
Py_DECREF(b);
|
||||
return NULL;
|
||||
|
@ -795,14 +795,14 @@ listextend(PyListObject *self, PyObject *b)
|
|||
|
||||
/* Guess a result list size. */
|
||||
n = _PyObject_LengthHint(b, 8);
|
||||
m = Py_Size(self);
|
||||
m = Py_SIZE(self);
|
||||
mn = m + n;
|
||||
if (mn >= m) {
|
||||
/* Make room. */
|
||||
if (list_resize(self, mn) == -1)
|
||||
goto error;
|
||||
/* Make the list sane again. */
|
||||
Py_Size(self) = m;
|
||||
Py_SIZE(self) = m;
|
||||
}
|
||||
/* Else m + n overflowed; on the chance that n lied, and there really
|
||||
* is enough room, ignore it. If n was telling the truth, we'll
|
||||
|
@ -821,10 +821,10 @@ listextend(PyListObject *self, PyObject *b)
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (Py_Size(self) < self->allocated) {
|
||||
if (Py_SIZE(self) < self->allocated) {
|
||||
/* steals ref */
|
||||
PyList_SET_ITEM(self, Py_Size(self), item);
|
||||
++Py_Size(self);
|
||||
PyList_SET_ITEM(self, Py_SIZE(self), item);
|
||||
++Py_SIZE(self);
|
||||
}
|
||||
else {
|
||||
int status = app1(self, item);
|
||||
|
@ -835,8 +835,8 @@ listextend(PyListObject *self, PyObject *b)
|
|||
}
|
||||
|
||||
/* Cut back result list if initial guess was too large. */
|
||||
if (Py_Size(self) < self->allocated)
|
||||
list_resize(self, Py_Size(self)); /* shrinking can't fail */
|
||||
if (Py_SIZE(self) < self->allocated)
|
||||
list_resize(self, Py_SIZE(self)); /* shrinking can't fail */
|
||||
|
||||
Py_DECREF(it);
|
||||
Py_RETURN_NONE;
|
||||
|
@ -875,20 +875,20 @@ listpop(PyListObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "|n:pop", &i))
|
||||
return NULL;
|
||||
|
||||
if (Py_Size(self) == 0) {
|
||||
if (Py_SIZE(self) == 0) {
|
||||
/* Special-case most common failure cause */
|
||||
PyErr_SetString(PyExc_IndexError, "pop from empty list");
|
||||
return NULL;
|
||||
}
|
||||
if (i < 0)
|
||||
i += Py_Size(self);
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
i += Py_SIZE(self);
|
||||
if (i < 0 || i >= Py_SIZE(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "pop index out of range");
|
||||
return NULL;
|
||||
}
|
||||
v = self->ob_item[i];
|
||||
if (i == Py_Size(self) - 1) {
|
||||
status = list_resize(self, Py_Size(self) - 1);
|
||||
if (i == Py_SIZE(self) - 1) {
|
||||
status = list_resize(self, Py_SIZE(self) - 1);
|
||||
assert(status >= 0);
|
||||
return v; /* and v now owns the reference the list had */
|
||||
}
|
||||
|
@ -2018,10 +2018,10 @@ listsort(PyListObject *self, PyObject *args, PyObject *kwds)
|
|||
* sorting (allowing mutations during sorting is a core-dump
|
||||
* factory, since ob_item may change).
|
||||
*/
|
||||
saved_ob_size = Py_Size(self);
|
||||
saved_ob_size = Py_SIZE(self);
|
||||
saved_ob_item = self->ob_item;
|
||||
saved_allocated = self->allocated;
|
||||
Py_Size(self) = 0;
|
||||
Py_SIZE(self) = 0;
|
||||
self->ob_item = NULL;
|
||||
self->allocated = -1; /* any operation will reset it to >= 0 */
|
||||
|
||||
|
@ -2127,8 +2127,8 @@ fail:
|
|||
|
||||
dsu_fail:
|
||||
final_ob_item = self->ob_item;
|
||||
i = Py_Size(self);
|
||||
Py_Size(self) = saved_ob_size;
|
||||
i = Py_SIZE(self);
|
||||
Py_SIZE(self) = saved_ob_size;
|
||||
self->ob_item = saved_ob_item;
|
||||
self->allocated = saved_allocated;
|
||||
if (final_ob_item != NULL) {
|
||||
|
@ -2163,8 +2163,8 @@ PyList_Sort(PyObject *v)
|
|||
static PyObject *
|
||||
listreverse(PyListObject *self)
|
||||
{
|
||||
if (Py_Size(self) > 1)
|
||||
reverse_slice(self->ob_item, self->ob_item + Py_Size(self));
|
||||
if (Py_SIZE(self) > 1)
|
||||
reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self));
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
@ -2177,8 +2177,8 @@ PyList_Reverse(PyObject *v)
|
|||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
if (Py_Size(self) > 1)
|
||||
reverse_slice(self->ob_item, self->ob_item + Py_Size(self));
|
||||
if (Py_SIZE(self) > 1)
|
||||
reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2192,7 +2192,7 @@ PyList_AsTuple(PyObject *v)
|
|||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
n = Py_Size(v);
|
||||
n = Py_SIZE(v);
|
||||
w = PyTuple_New(n);
|
||||
if (w == NULL)
|
||||
return NULL;
|
||||
|
@ -2210,7 +2210,7 @@ PyList_AsTuple(PyObject *v)
|
|||
static PyObject *
|
||||
listindex(PyListObject *self, PyObject *args)
|
||||
{
|
||||
Py_ssize_t i, start=0, stop=Py_Size(self);
|
||||
Py_ssize_t i, start=0, stop=Py_SIZE(self);
|
||||
PyObject *v;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O&O&:index", &v,
|
||||
|
@ -2218,16 +2218,16 @@ listindex(PyListObject *self, PyObject *args)
|
|||
_PyEval_SliceIndex, &stop))
|
||||
return NULL;
|
||||
if (start < 0) {
|
||||
start += Py_Size(self);
|
||||
start += Py_SIZE(self);
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
}
|
||||
if (stop < 0) {
|
||||
stop += Py_Size(self);
|
||||
stop += Py_SIZE(self);
|
||||
if (stop < 0)
|
||||
stop = 0;
|
||||
}
|
||||
for (i = start; i < stop && i < Py_Size(self); i++) {
|
||||
for (i = start; i < stop && i < Py_SIZE(self); i++) {
|
||||
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
|
||||
if (cmp > 0)
|
||||
return PyInt_FromSsize_t(i);
|
||||
|
@ -2244,7 +2244,7 @@ listcount(PyListObject *self, PyObject *v)
|
|||
Py_ssize_t count = 0;
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
for (i = 0; i < Py_SIZE(self); i++) {
|
||||
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
|
||||
if (cmp > 0)
|
||||
count++;
|
||||
|
@ -2259,7 +2259,7 @@ listremove(PyListObject *self, PyObject *v)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
for (i = 0; i < Py_SIZE(self); i++) {
|
||||
int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ);
|
||||
if (cmp > 0) {
|
||||
if (list_ass_slice(self, i, i+1,
|
||||
|
@ -2279,7 +2279,7 @@ list_traverse(PyListObject *o, visitproc visit, void *arg)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = Py_Size(o); --i >= 0; )
|
||||
for (i = Py_SIZE(o); --i >= 0; )
|
||||
Py_VISIT(o->ob_item[i]);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2298,7 +2298,7 @@ list_richcompare(PyObject *v, PyObject *w, int op)
|
|||
vl = (PyListObject *)v;
|
||||
wl = (PyListObject *)w;
|
||||
|
||||
if (Py_Size(vl) != Py_Size(wl) && (op == Py_EQ || op == Py_NE)) {
|
||||
if (Py_SIZE(vl) != Py_SIZE(wl) && (op == Py_EQ || op == Py_NE)) {
|
||||
/* Shortcut: if the lengths differ, the lists differ */
|
||||
PyObject *res;
|
||||
if (op == Py_EQ)
|
||||
|
@ -2310,7 +2310,7 @@ list_richcompare(PyObject *v, PyObject *w, int op)
|
|||
}
|
||||
|
||||
/* Search for the first index where items are different */
|
||||
for (i = 0; i < Py_Size(vl) && i < Py_Size(wl); i++) {
|
||||
for (i = 0; i < Py_SIZE(vl) && i < Py_SIZE(wl); i++) {
|
||||
int k = PyObject_RichCompareBool(vl->ob_item[i],
|
||||
wl->ob_item[i], Py_EQ);
|
||||
if (k < 0)
|
||||
|
@ -2319,10 +2319,10 @@ list_richcompare(PyObject *v, PyObject *w, int op)
|
|||
break;
|
||||
}
|
||||
|
||||
if (i >= Py_Size(vl) || i >= Py_Size(wl)) {
|
||||
if (i >= Py_SIZE(vl) || i >= Py_SIZE(wl)) {
|
||||
/* No more items to compare -- compare sizes */
|
||||
Py_ssize_t vs = Py_Size(vl);
|
||||
Py_ssize_t ws = Py_Size(wl);
|
||||
Py_ssize_t vs = Py_SIZE(vl);
|
||||
Py_ssize_t ws = Py_SIZE(wl);
|
||||
int cmp;
|
||||
PyObject *res;
|
||||
switch (op) {
|
||||
|
@ -2366,8 +2366,8 @@ list_init(PyListObject *self, PyObject *args, PyObject *kw)
|
|||
return -1;
|
||||
|
||||
/* Verify list invariants established by PyType_GenericAlloc() */
|
||||
assert(0 <= Py_Size(self));
|
||||
assert(Py_Size(self) <= self->allocated || self->allocated == -1);
|
||||
assert(0 <= Py_SIZE(self));
|
||||
assert(Py_SIZE(self) <= self->allocated || self->allocated == -1);
|
||||
assert(self->ob_item != NULL ||
|
||||
self->allocated == 0 || self->allocated == -1);
|
||||
|
||||
|
@ -2464,7 +2464,7 @@ list_subscript(PyListObject* self, PyObject* item)
|
|||
PyObject* it;
|
||||
PyObject **src, **dest;
|
||||
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
|
||||
&start, &stop, &step, &slicelength) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2513,7 +2513,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
|||
else if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
|
||||
&start, &stop, &step, &slicelength) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -2561,8 +2561,8 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
|||
|
||||
garbage[i] = PyList_GET_ITEM(self, cur);
|
||||
|
||||
if (cur + step >= Py_Size(self)) {
|
||||
lim = Py_Size(self) - cur - 1;
|
||||
if (cur + step >= Py_SIZE(self)) {
|
||||
lim = Py_SIZE(self) - cur - 1;
|
||||
}
|
||||
|
||||
memmove(self->ob_item + cur - i,
|
||||
|
@ -2570,15 +2570,15 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
|||
lim * sizeof(PyObject *));
|
||||
}
|
||||
cur = start + slicelength*step;
|
||||
if (cur < Py_Size(self)) {
|
||||
if (cur < Py_SIZE(self)) {
|
||||
memmove(self->ob_item + cur - slicelength,
|
||||
self->ob_item + cur,
|
||||
(Py_Size(self) - cur) *
|
||||
(Py_SIZE(self) - cur) *
|
||||
sizeof(PyObject *));
|
||||
}
|
||||
|
||||
Py_Size(self) -= slicelength;
|
||||
list_resize(self, Py_Size(self));
|
||||
Py_SIZE(self) -= slicelength;
|
||||
list_resize(self, Py_SIZE(self));
|
||||
|
||||
for (i = 0; i < slicelength; i++) {
|
||||
Py_DECREF(garbage[i]);
|
||||
|
|
|
@ -50,13 +50,13 @@ static PyObject *long_format(PyObject *aa, int base, int addL);
|
|||
static PyLongObject *
|
||||
long_normalize(register PyLongObject *v)
|
||||
{
|
||||
Py_ssize_t j = ABS(Py_Size(v));
|
||||
Py_ssize_t j = ABS(Py_SIZE(v));
|
||||
Py_ssize_t i = j;
|
||||
|
||||
while (i > 0 && v->ob_digit[i-1] == 0)
|
||||
--i;
|
||||
if (i != j)
|
||||
Py_Size(v) = (Py_Size(v) < 0) ? -(i) : i;
|
||||
Py_SIZE(v) = (Py_SIZE(v) < 0) ? -(i) : i;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ PyLong_FromUnsignedLong(unsigned long ival)
|
|||
v = _PyLong_New(ndigits);
|
||||
if (v != NULL) {
|
||||
digit *p = v->ob_digit;
|
||||
Py_Size(v) = ndigits;
|
||||
Py_SIZE(v) = ndigits;
|
||||
while (ival) {
|
||||
*p++ = (digit)(ival & MASK);
|
||||
ival >>= SHIFT;
|
||||
|
@ -189,7 +189,7 @@ PyLong_FromDouble(double dval)
|
|||
frac = ldexp(frac, SHIFT);
|
||||
}
|
||||
if (neg)
|
||||
Py_Size(v) = -(Py_Size(v));
|
||||
Py_SIZE(v) = -(Py_SIZE(v));
|
||||
return (PyObject *)v;
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
|||
return (unsigned long) -1;
|
||||
}
|
||||
v = (PyLongObject *)vv;
|
||||
i = Py_Size(v);
|
||||
i = Py_SIZE(v);
|
||||
x = 0;
|
||||
if (i < 0) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
|
@ -381,7 +381,7 @@ _PyLong_Sign(PyObject *vv)
|
|||
assert(v != NULL);
|
||||
assert(PyLong_Check(v));
|
||||
|
||||
return Py_Size(v) == 0 ? 0 : (Py_Size(v) < 0 ? -1 : 1);
|
||||
return Py_SIZE(v) == 0 ? 0 : (Py_SIZE(v) < 0 ? -1 : 1);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
@ -393,7 +393,7 @@ _PyLong_NumBits(PyObject *vv)
|
|||
|
||||
assert(v != NULL);
|
||||
assert(PyLong_Check(v));
|
||||
ndigits = ABS(Py_Size(v));
|
||||
ndigits = ABS(Py_SIZE(v));
|
||||
assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
|
||||
if (ndigits > 0) {
|
||||
digit msd = v->ob_digit[ndigits - 1];
|
||||
|
@ -519,7 +519,7 @@ _PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
|||
}
|
||||
}
|
||||
|
||||
Py_Size(v) = is_signed ? -idigit : idigit;
|
||||
Py_SIZE(v) = is_signed ? -idigit : idigit;
|
||||
return (PyObject *)long_normalize(v);
|
||||
}
|
||||
|
||||
|
@ -540,8 +540,8 @@ _PyLong_AsByteArray(PyLongObject* v,
|
|||
|
||||
assert(v != NULL && PyLong_Check(v));
|
||||
|
||||
if (Py_Size(v) < 0) {
|
||||
ndigits = -(Py_Size(v));
|
||||
if (Py_SIZE(v) < 0) {
|
||||
ndigits = -(Py_SIZE(v));
|
||||
if (!is_signed) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"can't convert negative long to unsigned");
|
||||
|
@ -550,7 +550,7 @@ _PyLong_AsByteArray(PyLongObject* v,
|
|||
do_twos_comp = 1;
|
||||
}
|
||||
else {
|
||||
ndigits = Py_Size(v);
|
||||
ndigits = Py_SIZE(v);
|
||||
do_twos_comp = 0;
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ _PyLong_AsScaledDouble(PyObject *vv, int *exponent)
|
|||
return -1;
|
||||
}
|
||||
v = (PyLongObject *)vv;
|
||||
i = Py_Size(v);
|
||||
i = Py_SIZE(v);
|
||||
sign = 1;
|
||||
if (i < 0) {
|
||||
sign = -1;
|
||||
|
@ -847,7 +847,7 @@ PyLong_FromLongLong(PY_LONG_LONG ival)
|
|||
v = _PyLong_New(ndigits);
|
||||
if (v != NULL) {
|
||||
digit *p = v->ob_digit;
|
||||
Py_Size(v) = negative ? -ndigits : ndigits;
|
||||
Py_SIZE(v) = negative ? -ndigits : ndigits;
|
||||
t = (unsigned PY_LONG_LONG)ival;
|
||||
while (t) {
|
||||
*p++ = (digit)(t & MASK);
|
||||
|
@ -875,7 +875,7 @@ PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival)
|
|||
v = _PyLong_New(ndigits);
|
||||
if (v != NULL) {
|
||||
digit *p = v->ob_digit;
|
||||
Py_Size(v) = ndigits;
|
||||
Py_SIZE(v) = ndigits;
|
||||
while (ival) {
|
||||
*p++ = (digit)(ival & MASK);
|
||||
ival >>= SHIFT;
|
||||
|
@ -1117,7 +1117,7 @@ mul1(PyLongObject *a, wdigit n)
|
|||
static PyLongObject *
|
||||
muladd1(PyLongObject *a, wdigit n, wdigit extra)
|
||||
{
|
||||
Py_ssize_t size_a = ABS(Py_Size(a));
|
||||
Py_ssize_t size_a = ABS(Py_SIZE(a));
|
||||
PyLongObject *z = _PyLong_New(size_a+1);
|
||||
twodigits carry = extra;
|
||||
Py_ssize_t i;
|
||||
|
@ -1163,7 +1163,7 @@ inplace_divrem1(digit *pout, digit *pin, Py_ssize_t size, digit n)
|
|||
static PyLongObject *
|
||||
divrem1(PyLongObject *a, digit n, digit *prem)
|
||||
{
|
||||
const Py_ssize_t size = ABS(Py_Size(a));
|
||||
const Py_ssize_t size = ABS(Py_SIZE(a));
|
||||
PyLongObject *z;
|
||||
|
||||
assert(n > 0 && n <= MASK);
|
||||
|
@ -1194,7 +1194,7 @@ long_format(PyObject *aa, int base, int addL)
|
|||
return NULL;
|
||||
}
|
||||
assert(base >= 2 && base <= 36);
|
||||
size_a = ABS(Py_Size(a));
|
||||
size_a = ABS(Py_SIZE(a));
|
||||
|
||||
/* Compute a rough upper bound for the length of the string */
|
||||
i = base;
|
||||
|
@ -1597,7 +1597,7 @@ digit beyond the first.
|
|||
z = _PyLong_New(size_z);
|
||||
if (z == NULL)
|
||||
return NULL;
|
||||
Py_Size(z) = 0;
|
||||
Py_SIZE(z) = 0;
|
||||
|
||||
/* `convwidth` consecutive input digits are treated as a single
|
||||
* digit in base `convmultmax`.
|
||||
|
@ -1627,7 +1627,7 @@ digit beyond the first.
|
|||
|
||||
/* Multiply z by convmult, and add c. */
|
||||
pz = z->ob_digit;
|
||||
pzstop = pz + Py_Size(z);
|
||||
pzstop = pz + Py_SIZE(z);
|
||||
for (; pz < pzstop; ++pz) {
|
||||
c += (twodigits)*pz * convmult;
|
||||
*pz = (digit)(c & MASK);
|
||||
|
@ -1636,14 +1636,14 @@ digit beyond the first.
|
|||
/* carry off the current end? */
|
||||
if (c) {
|
||||
assert(c < BASE);
|
||||
if (Py_Size(z) < size_z) {
|
||||
if (Py_SIZE(z) < size_z) {
|
||||
*pz = (digit)c;
|
||||
++Py_Size(z);
|
||||
++Py_SIZE(z);
|
||||
}
|
||||
else {
|
||||
PyLongObject *tmp;
|
||||
/* Extremely rare. Get more space. */
|
||||
assert(Py_Size(z) == size_z);
|
||||
assert(Py_SIZE(z) == size_z);
|
||||
tmp = _PyLong_New(size_z + 1);
|
||||
if (tmp == NULL) {
|
||||
Py_DECREF(z);
|
||||
|
@ -1665,7 +1665,7 @@ digit beyond the first.
|
|||
if (str == start)
|
||||
goto onError;
|
||||
if (sign < 0)
|
||||
Py_Size(z) = -(Py_Size(z));
|
||||
Py_SIZE(z) = -(Py_SIZE(z));
|
||||
if (*str == 'L' || *str == 'l')
|
||||
str++;
|
||||
while (*str && isspace(Py_CHARMASK(*str)))
|
||||
|
@ -1726,7 +1726,7 @@ static int
|
|||
long_divrem(PyLongObject *a, PyLongObject *b,
|
||||
PyLongObject **pdiv, PyLongObject **prem)
|
||||
{
|
||||
Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
|
||||
Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
|
||||
PyLongObject *z;
|
||||
|
||||
if (size_b == 0) {
|
||||
|
@ -1778,7 +1778,7 @@ long_divrem(PyLongObject *a, PyLongObject *b,
|
|||
static PyLongObject *
|
||||
x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
|
||||
{
|
||||
Py_ssize_t size_v = ABS(Py_Size(v1)), size_w = ABS(Py_Size(w1));
|
||||
Py_ssize_t size_v = ABS(Py_SIZE(v1)), size_w = ABS(Py_SIZE(w1));
|
||||
digit d = (digit) ((twodigits)BASE / (w1->ob_digit[size_w-1] + 1));
|
||||
PyLongObject *v = mul1(v1, d);
|
||||
PyLongObject *w = mul1(w1, d);
|
||||
|
@ -1792,10 +1792,10 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
|
|||
}
|
||||
|
||||
assert(size_v >= size_w && size_w > 1); /* Assert checks by div() */
|
||||
assert(Py_Refcnt(v) == 1); /* Since v will be used as accumulator! */
|
||||
assert(size_w == ABS(Py_Size(w))); /* That's how d was calculated */
|
||||
assert(Py_REFCNT(v) == 1); /* Since v will be used as accumulator! */
|
||||
assert(size_w == ABS(Py_SIZE(w))); /* That's how d was calculated */
|
||||
|
||||
size_v = ABS(Py_Size(v));
|
||||
size_v = ABS(Py_SIZE(v));
|
||||
k = size_v - size_w;
|
||||
a = _PyLong_New(k + 1);
|
||||
|
||||
|
@ -1878,7 +1878,7 @@ x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem)
|
|||
static void
|
||||
long_dealloc(PyObject *v)
|
||||
{
|
||||
Py_Type(v)->tp_free(v);
|
||||
Py_TYPE(v)->tp_free(v);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1898,21 +1898,21 @@ long_compare(PyLongObject *a, PyLongObject *b)
|
|||
{
|
||||
Py_ssize_t sign;
|
||||
|
||||
if (Py_Size(a) != Py_Size(b)) {
|
||||
if (ABS(Py_Size(a)) == 0 && ABS(Py_Size(b)) == 0)
|
||||
if (Py_SIZE(a) != Py_SIZE(b)) {
|
||||
if (ABS(Py_SIZE(a)) == 0 && ABS(Py_SIZE(b)) == 0)
|
||||
sign = 0;
|
||||
else
|
||||
sign = Py_Size(a) - Py_Size(b);
|
||||
sign = Py_SIZE(a) - Py_SIZE(b);
|
||||
}
|
||||
else {
|
||||
Py_ssize_t i = ABS(Py_Size(a));
|
||||
Py_ssize_t i = ABS(Py_SIZE(a));
|
||||
while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
|
||||
;
|
||||
if (i < 0)
|
||||
sign = 0;
|
||||
else {
|
||||
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
|
||||
if (Py_Size(a) < 0)
|
||||
if (Py_SIZE(a) < 0)
|
||||
sign = -sign;
|
||||
}
|
||||
}
|
||||
|
@ -1963,7 +1963,7 @@ long_hash(PyLongObject *v)
|
|||
static PyLongObject *
|
||||
x_add(PyLongObject *a, PyLongObject *b)
|
||||
{
|
||||
Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
|
||||
Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
|
||||
PyLongObject *z;
|
||||
int i;
|
||||
digit carry = 0;
|
||||
|
@ -1997,7 +1997,7 @@ x_add(PyLongObject *a, PyLongObject *b)
|
|||
static PyLongObject *
|
||||
x_sub(PyLongObject *a, PyLongObject *b)
|
||||
{
|
||||
Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b));
|
||||
Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b));
|
||||
PyLongObject *z;
|
||||
Py_ssize_t i;
|
||||
int sign = 1;
|
||||
|
@ -2107,15 +2107,15 @@ static PyLongObject *
|
|||
x_mul(PyLongObject *a, PyLongObject *b)
|
||||
{
|
||||
PyLongObject *z;
|
||||
Py_ssize_t size_a = ABS(Py_Size(a));
|
||||
Py_ssize_t size_b = ABS(Py_Size(b));
|
||||
Py_ssize_t size_a = ABS(Py_SIZE(a));
|
||||
Py_ssize_t size_b = ABS(Py_SIZE(b));
|
||||
Py_ssize_t i;
|
||||
|
||||
z = _PyLong_New(size_a + size_b);
|
||||
if (z == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(z->ob_digit, 0, Py_Size(z) * sizeof(digit));
|
||||
memset(z->ob_digit, 0, Py_SIZE(z) * sizeof(digit));
|
||||
if (a == b) {
|
||||
/* Efficient squaring per HAC, Algorithm 14.16:
|
||||
* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf
|
||||
|
@ -2199,7 +2199,7 @@ kmul_split(PyLongObject *n, Py_ssize_t size, PyLongObject **high, PyLongObject *
|
|||
{
|
||||
PyLongObject *hi, *lo;
|
||||
Py_ssize_t size_lo, size_hi;
|
||||
const Py_ssize_t size_n = ABS(Py_Size(n));
|
||||
const Py_ssize_t size_n = ABS(Py_SIZE(n));
|
||||
|
||||
size_lo = MIN(size_n, size);
|
||||
size_hi = size_n - size_lo;
|
||||
|
@ -2228,8 +2228,8 @@ static PyLongObject *k_lopsided_mul(PyLongObject *a, PyLongObject *b);
|
|||
static PyLongObject *
|
||||
k_mul(PyLongObject *a, PyLongObject *b)
|
||||
{
|
||||
Py_ssize_t asize = ABS(Py_Size(a));
|
||||
Py_ssize_t bsize = ABS(Py_Size(b));
|
||||
Py_ssize_t asize = ABS(Py_SIZE(a));
|
||||
Py_ssize_t bsize = ABS(Py_SIZE(b));
|
||||
PyLongObject *ah = NULL;
|
||||
PyLongObject *al = NULL;
|
||||
PyLongObject *bh = NULL;
|
||||
|
@ -2281,7 +2281,7 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
|||
/* Split a & b into hi & lo pieces. */
|
||||
shift = bsize >> 1;
|
||||
if (kmul_split(a, shift, &ah, &al) < 0) goto fail;
|
||||
assert(Py_Size(ah) > 0); /* the split isn't degenerate */
|
||||
assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */
|
||||
|
||||
if (a == b) {
|
||||
bh = ah;
|
||||
|
@ -2312,20 +2312,20 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
|||
if (ret == NULL) goto fail;
|
||||
#ifdef Py_DEBUG
|
||||
/* Fill with trash, to catch reference to uninitialized digits. */
|
||||
memset(ret->ob_digit, 0xDF, Py_Size(ret) * sizeof(digit));
|
||||
memset(ret->ob_digit, 0xDF, Py_SIZE(ret) * sizeof(digit));
|
||||
#endif
|
||||
|
||||
/* 2. t1 <- ah*bh, and copy into high digits of result. */
|
||||
if ((t1 = k_mul(ah, bh)) == NULL) goto fail;
|
||||
assert(Py_Size(t1) >= 0);
|
||||
assert(2*shift + Py_Size(t1) <= Py_Size(ret));
|
||||
assert(Py_SIZE(t1) >= 0);
|
||||
assert(2*shift + Py_SIZE(t1) <= Py_SIZE(ret));
|
||||
memcpy(ret->ob_digit + 2*shift, t1->ob_digit,
|
||||
Py_Size(t1) * sizeof(digit));
|
||||
Py_SIZE(t1) * sizeof(digit));
|
||||
|
||||
/* Zero-out the digits higher than the ah*bh copy. */
|
||||
i = Py_Size(ret) - 2*shift - Py_Size(t1);
|
||||
i = Py_SIZE(ret) - 2*shift - Py_SIZE(t1);
|
||||
if (i)
|
||||
memset(ret->ob_digit + 2*shift + Py_Size(t1), 0,
|
||||
memset(ret->ob_digit + 2*shift + Py_SIZE(t1), 0,
|
||||
i * sizeof(digit));
|
||||
|
||||
/* 3. t2 <- al*bl, and copy into the low digits. */
|
||||
|
@ -2333,23 +2333,23 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
|||
Py_DECREF(t1);
|
||||
goto fail;
|
||||
}
|
||||
assert(Py_Size(t2) >= 0);
|
||||
assert(Py_Size(t2) <= 2*shift); /* no overlap with high digits */
|
||||
memcpy(ret->ob_digit, t2->ob_digit, Py_Size(t2) * sizeof(digit));
|
||||
assert(Py_SIZE(t2) >= 0);
|
||||
assert(Py_SIZE(t2) <= 2*shift); /* no overlap with high digits */
|
||||
memcpy(ret->ob_digit, t2->ob_digit, Py_SIZE(t2) * sizeof(digit));
|
||||
|
||||
/* Zero out remaining digits. */
|
||||
i = 2*shift - Py_Size(t2); /* number of uninitialized digits */
|
||||
i = 2*shift - Py_SIZE(t2); /* number of uninitialized digits */
|
||||
if (i)
|
||||
memset(ret->ob_digit + Py_Size(t2), 0, i * sizeof(digit));
|
||||
memset(ret->ob_digit + Py_SIZE(t2), 0, i * sizeof(digit));
|
||||
|
||||
/* 4 & 5. Subtract ah*bh (t1) and al*bl (t2). We do al*bl first
|
||||
* because it's fresher in cache.
|
||||
*/
|
||||
i = Py_Size(ret) - shift; /* # digits after shift */
|
||||
(void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_Size(t2));
|
||||
i = Py_SIZE(ret) - shift; /* # digits after shift */
|
||||
(void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_SIZE(t2));
|
||||
Py_DECREF(t2);
|
||||
|
||||
(void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_Size(t1));
|
||||
(void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_SIZE(t1));
|
||||
Py_DECREF(t1);
|
||||
|
||||
/* 6. t3 <- (ah+al)(bh+bl), and add into result. */
|
||||
|
@ -2374,12 +2374,12 @@ k_mul(PyLongObject *a, PyLongObject *b)
|
|||
Py_DECREF(t1);
|
||||
Py_DECREF(t2);
|
||||
if (t3 == NULL) goto fail;
|
||||
assert(Py_Size(t3) >= 0);
|
||||
assert(Py_SIZE(t3) >= 0);
|
||||
|
||||
/* Add t3. It's not obvious why we can't run out of room here.
|
||||
* See the (*) comment after this function.
|
||||
*/
|
||||
(void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_Size(t3));
|
||||
(void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_SIZE(t3));
|
||||
Py_DECREF(t3);
|
||||
|
||||
return long_normalize(ret);
|
||||
|
@ -2449,8 +2449,8 @@ ah*bh and al*bl too.
|
|||
static PyLongObject *
|
||||
k_lopsided_mul(PyLongObject *a, PyLongObject *b)
|
||||
{
|
||||
const Py_ssize_t asize = ABS(Py_Size(a));
|
||||
Py_ssize_t bsize = ABS(Py_Size(b));
|
||||
const Py_ssize_t asize = ABS(Py_SIZE(a));
|
||||
Py_ssize_t bsize = ABS(Py_SIZE(b));
|
||||
Py_ssize_t nbdone; /* # of b digits already multiplied */
|
||||
PyLongObject *ret;
|
||||
PyLongObject *bslice = NULL;
|
||||
|
@ -2462,7 +2462,7 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
|
|||
ret = _PyLong_New(asize + bsize);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
memset(ret->ob_digit, 0, Py_Size(ret) * sizeof(digit));
|
||||
memset(ret->ob_digit, 0, Py_SIZE(ret) * sizeof(digit));
|
||||
|
||||
/* Successive slices of b are copied into bslice. */
|
||||
bslice = _PyLong_New(asize);
|
||||
|
@ -2477,14 +2477,14 @@ k_lopsided_mul(PyLongObject *a, PyLongObject *b)
|
|||
/* Multiply the next slice of b by a. */
|
||||
memcpy(bslice->ob_digit, b->ob_digit + nbdone,
|
||||
nbtouse * sizeof(digit));
|
||||
Py_Size(bslice) = nbtouse;
|
||||
Py_SIZE(bslice) = nbtouse;
|
||||
product = k_mul(a, bslice);
|
||||
if (product == NULL)
|
||||
goto fail;
|
||||
|
||||
/* Add into result. */
|
||||
(void)v_iadd(ret->ob_digit + nbdone, Py_Size(ret) - nbdone,
|
||||
product->ob_digit, Py_Size(product));
|
||||
(void)v_iadd(ret->ob_digit + nbdone, Py_SIZE(ret) - nbdone,
|
||||
product->ob_digit, Py_SIZE(product));
|
||||
Py_DECREF(product);
|
||||
|
||||
bsize -= nbtouse;
|
||||
|
@ -2548,8 +2548,8 @@ l_divmod(PyLongObject *v, PyLongObject *w,
|
|||
|
||||
if (long_divrem(v, w, &div, &mod) < 0)
|
||||
return -1;
|
||||
if ((Py_Size(mod) < 0 && Py_Size(w) > 0) ||
|
||||
(Py_Size(mod) > 0 && Py_Size(w) < 0)) {
|
||||
if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) ||
|
||||
(Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) {
|
||||
PyLongObject *temp;
|
||||
PyLongObject *one;
|
||||
temp = (PyLongObject *) long_add(mod, w);
|
||||
|
@ -2737,7 +2737,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
return Py_NotImplemented;
|
||||
}
|
||||
|
||||
if (Py_Size(b) < 0) { /* if exponent is negative */
|
||||
if (Py_SIZE(b) < 0) { /* if exponent is negative */
|
||||
if (c) {
|
||||
PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
|
||||
"cannot be negative when 3rd argument specified");
|
||||
|
@ -2756,7 +2756,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
if (c) {
|
||||
/* if modulus == 0:
|
||||
raise ValueError() */
|
||||
if (Py_Size(c) == 0) {
|
||||
if (Py_SIZE(c) == 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"pow() 3rd argument cannot be 0");
|
||||
goto Error;
|
||||
|
@ -2765,7 +2765,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
/* if modulus < 0:
|
||||
negativeOutput = True
|
||||
modulus = -modulus */
|
||||
if (Py_Size(c) < 0) {
|
||||
if (Py_SIZE(c) < 0) {
|
||||
negativeOutput = 1;
|
||||
temp = (PyLongObject *)_PyLong_Copy(c);
|
||||
if (temp == NULL)
|
||||
|
@ -2778,7 +2778,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
|
||||
/* if modulus == 1:
|
||||
return 0 */
|
||||
if ((Py_Size(c) == 1) && (c->ob_digit[0] == 1)) {
|
||||
if ((Py_SIZE(c) == 1) && (c->ob_digit[0] == 1)) {
|
||||
z = (PyLongObject *)PyLong_FromLong(0L);
|
||||
goto Done;
|
||||
}
|
||||
|
@ -2786,7 +2786,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
/* if base < 0:
|
||||
base = base % modulus
|
||||
Having the base positive just makes things easier. */
|
||||
if (Py_Size(a) < 0) {
|
||||
if (Py_SIZE(a) < 0) {
|
||||
if (l_divmod(a, c, NULL, &temp) < 0)
|
||||
goto Error;
|
||||
Py_DECREF(a);
|
||||
|
@ -2827,10 +2827,10 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
REDUCE(result) \
|
||||
}
|
||||
|
||||
if (Py_Size(b) <= FIVEARY_CUTOFF) {
|
||||
if (Py_SIZE(b) <= FIVEARY_CUTOFF) {
|
||||
/* Left-to-right binary exponentiation (HAC Algorithm 14.79) */
|
||||
/* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf */
|
||||
for (i = Py_Size(b) - 1; i >= 0; --i) {
|
||||
for (i = Py_SIZE(b) - 1; i >= 0; --i) {
|
||||
digit bi = b->ob_digit[i];
|
||||
|
||||
for (j = 1 << (SHIFT-1); j != 0; j >>= 1) {
|
||||
|
@ -2847,7 +2847,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
for (i = 1; i < 32; ++i)
|
||||
MULT(table[i-1], a, table[i])
|
||||
|
||||
for (i = Py_Size(b) - 1; i >= 0; --i) {
|
||||
for (i = Py_SIZE(b) - 1; i >= 0; --i) {
|
||||
const digit bi = b->ob_digit[i];
|
||||
|
||||
for (j = SHIFT - 5; j >= 0; j -= 5) {
|
||||
|
@ -2860,7 +2860,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
}
|
||||
}
|
||||
|
||||
if (negativeOutput && (Py_Size(z) != 0)) {
|
||||
if (negativeOutput && (Py_SIZE(z) != 0)) {
|
||||
temp = (PyLongObject *)long_sub(z, c);
|
||||
if (temp == NULL)
|
||||
goto Error;
|
||||
|
@ -2877,7 +2877,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
|
|||
}
|
||||
/* fall through */
|
||||
Done:
|
||||
if (Py_Size(b) > FIVEARY_CUTOFF) {
|
||||
if (Py_SIZE(b) > FIVEARY_CUTOFF) {
|
||||
for (i = 0; i < 32; ++i)
|
||||
Py_XDECREF(table[i]);
|
||||
}
|
||||
|
@ -2901,7 +2901,7 @@ long_invert(PyLongObject *v)
|
|||
Py_DECREF(w);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
Py_Size(x) = -(Py_Size(x));
|
||||
Py_SIZE(x) = -(Py_SIZE(x));
|
||||
return (PyObject *)x;
|
||||
}
|
||||
|
||||
|
@ -2943,7 +2943,7 @@ long_abs(PyLongObject *v)
|
|||
static int
|
||||
long_nonzero(PyLongObject *v)
|
||||
{
|
||||
return ABS(Py_Size(v)) != 0;
|
||||
return ABS(Py_SIZE(v)) != 0;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -2957,7 +2957,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
|
|||
|
||||
CONVERT_BINOP((PyObject *)v, (PyObject *)w, &a, &b);
|
||||
|
||||
if (Py_Size(a) < 0) {
|
||||
if (Py_SIZE(a) < 0) {
|
||||
/* Right shifting negative numbers is harder */
|
||||
PyLongObject *a1, *a2;
|
||||
a1 = (PyLongObject *) long_invert(a);
|
||||
|
@ -2981,7 +2981,7 @@ long_rshift(PyLongObject *v, PyLongObject *w)
|
|||
goto rshift_error;
|
||||
}
|
||||
wordshift = shiftby / SHIFT;
|
||||
newsize = ABS(Py_Size(a)) - wordshift;
|
||||
newsize = ABS(Py_SIZE(a)) - wordshift;
|
||||
if (newsize <= 0) {
|
||||
z = _PyLong_New(0);
|
||||
Py_DECREF(a);
|
||||
|
@ -2995,8 +2995,8 @@ long_rshift(PyLongObject *v, PyLongObject *w)
|
|||
z = _PyLong_New(newsize);
|
||||
if (z == NULL)
|
||||
goto rshift_error;
|
||||
if (Py_Size(a) < 0)
|
||||
Py_Size(z) = -(Py_Size(z));
|
||||
if (Py_SIZE(a) < 0)
|
||||
Py_SIZE(z) = -(Py_SIZE(z));
|
||||
for (i = 0, j = wordshift; i < newsize; i++, j++) {
|
||||
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
|
||||
if (i+1 < newsize)
|
||||
|
@ -3084,7 +3084,7 @@ long_bitwise(PyLongObject *a,
|
|||
digit diga, digb;
|
||||
PyObject *v;
|
||||
|
||||
if (Py_Size(a) < 0) {
|
||||
if (Py_SIZE(a) < 0) {
|
||||
a = (PyLongObject *) long_invert(a);
|
||||
if (a == NULL)
|
||||
return NULL;
|
||||
|
@ -3094,7 +3094,7 @@ long_bitwise(PyLongObject *a,
|
|||
Py_INCREF(a);
|
||||
maska = 0;
|
||||
}
|
||||
if (Py_Size(b) < 0) {
|
||||
if (Py_SIZE(b) < 0) {
|
||||
b = (PyLongObject *) long_invert(b);
|
||||
if (b == NULL) {
|
||||
Py_DECREF(a);
|
||||
|
@ -3143,8 +3143,8 @@ long_bitwise(PyLongObject *a,
|
|||
whose length should be ignored.
|
||||
*/
|
||||
|
||||
size_a = Py_Size(a);
|
||||
size_b = Py_Size(b);
|
||||
size_a = Py_SIZE(a);
|
||||
size_b = Py_SIZE(b);
|
||||
size_z = op == '&'
|
||||
? (maska
|
||||
? size_b
|
||||
|
@ -3351,7 +3351,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
if (tmp == NULL)
|
||||
return NULL;
|
||||
assert(PyLong_CheckExact(tmp));
|
||||
n = Py_Size(tmp);
|
||||
n = Py_SIZE(tmp);
|
||||
if (n < 0)
|
||||
n = -n;
|
||||
newobj = (PyLongObject *)type->tp_alloc(type, n);
|
||||
|
@ -3360,7 +3360,7 @@ long_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
assert(PyLong_Check(newobj));
|
||||
Py_Size(newobj) = Py_Size(tmp);
|
||||
Py_SIZE(newobj) = Py_SIZE(tmp);
|
||||
for (i = 0; i < n; i++)
|
||||
newobj->ob_digit[i] = tmp->ob_digit[i];
|
||||
Py_DECREF(tmp);
|
||||
|
|
|
@ -178,7 +178,7 @@ module_dealloc(PyModuleObject *m)
|
|||
_PyModule_Clear((PyObject *)m);
|
||||
Py_DECREF(m->md_dict);
|
||||
}
|
||||
Py_Type(m)->tp_free((PyObject *)m);
|
||||
Py_TYPE(m)->tp_free((PyObject *)m);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
@ -214,7 +214,7 @@ PyObject_Init(PyObject *op, PyTypeObject *tp)
|
|||
if (op == NULL)
|
||||
return PyErr_NoMemory();
|
||||
/* Any changes should be reflected in PyObject_INIT (objimpl.h) */
|
||||
Py_Type(op) = tp;
|
||||
Py_TYPE(op) = tp;
|
||||
_Py_NewReference(op);
|
||||
return op;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
|
|||
return (PyVarObject *) PyErr_NoMemory();
|
||||
/* Any changes should be reflected in PyObject_INIT_VAR */
|
||||
op->ob_size = size;
|
||||
Py_Type(op) = tp;
|
||||
Py_TYPE(op) = tp;
|
||||
_Py_NewReference((PyObject *)op);
|
||||
return op;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
|
|||
fprintf(fp, "<refcnt %ld at %p>",
|
||||
(long)op->ob_refcnt, op);
|
||||
Py_END_ALLOW_THREADS
|
||||
else if (Py_Type(op)->tp_print == NULL) {
|
||||
else if (Py_TYPE(op)->tp_print == NULL) {
|
||||
PyObject *s;
|
||||
if (flags & Py_PRINT_RAW)
|
||||
s = PyObject_Str(op);
|
||||
|
@ -306,7 +306,7 @@ internal_print(PyObject *op, FILE *fp, int flags, int nesting)
|
|||
Py_XDECREF(s);
|
||||
}
|
||||
else
|
||||
ret = (*Py_Type(op)->tp_print)(op, fp, flags);
|
||||
ret = (*Py_TYPE(op)->tp_print)(op, fp, flags);
|
||||
}
|
||||
if (ret == 0) {
|
||||
if (ferror(fp)) {
|
||||
|
@ -339,7 +339,7 @@ void _PyObject_Dump(PyObject* op)
|
|||
"type : %s\n"
|
||||
"refcount: %ld\n"
|
||||
"address : %p\n",
|
||||
Py_Type(op)==NULL ? "NULL" : Py_Type(op)->tp_name,
|
||||
Py_TYPE(op)==NULL ? "NULL" : Py_TYPE(op)->tp_name,
|
||||
(long)op->ob_refcnt,
|
||||
op);
|
||||
}
|
||||
|
@ -358,12 +358,12 @@ PyObject_Repr(PyObject *v)
|
|||
#endif
|
||||
if (v == NULL)
|
||||
return PyString_FromString("<NULL>");
|
||||
else if (Py_Type(v)->tp_repr == NULL)
|
||||
else if (Py_TYPE(v)->tp_repr == NULL)
|
||||
return PyString_FromFormat("<%s object at %p>",
|
||||
Py_Type(v)->tp_name, v);
|
||||
Py_TYPE(v)->tp_name, v);
|
||||
else {
|
||||
PyObject *res;
|
||||
res = (*Py_Type(v)->tp_repr)(v);
|
||||
res = (*Py_TYPE(v)->tp_repr)(v);
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
@ -380,7 +380,7 @@ PyObject_Repr(PyObject *v)
|
|||
if (!PyString_Check(res)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__repr__ returned non-string (type %.200s)",
|
||||
Py_Type(res)->tp_name);
|
||||
Py_TYPE(res)->tp_name);
|
||||
Py_DECREF(res);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -405,14 +405,14 @@ _PyObject_Str(PyObject *v)
|
|||
return v;
|
||||
}
|
||||
#endif
|
||||
if (Py_Type(v)->tp_str == NULL)
|
||||
if (Py_TYPE(v)->tp_str == NULL)
|
||||
return PyObject_Repr(v);
|
||||
|
||||
/* It is possible for a type to have a tp_str representation that loops
|
||||
infinitely. */
|
||||
if (Py_EnterRecursiveCall(" while getting the str of an object"))
|
||||
return NULL;
|
||||
res = (*Py_Type(v)->tp_str)(v);
|
||||
res = (*Py_TYPE(v)->tp_str)(v);
|
||||
Py_LeaveRecursiveCall();
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
|
@ -423,7 +423,7 @@ _PyObject_Str(PyObject *v)
|
|||
if (!type_ok) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__str__ returned non-string (type %.200s)",
|
||||
Py_Type(res)->tp_name);
|
||||
Py_TYPE(res)->tp_name);
|
||||
Py_DECREF(res);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -497,8 +497,8 @@ PyObject_Unicode(PyObject *v)
|
|||
res = v;
|
||||
}
|
||||
else {
|
||||
if (Py_Type(v)->tp_str != NULL)
|
||||
res = (*Py_Type(v)->tp_str)(v);
|
||||
if (Py_TYPE(v)->tp_str != NULL)
|
||||
res = (*Py_TYPE(v)->tp_str)(v);
|
||||
else
|
||||
res = PyObject_Repr(v);
|
||||
}
|
||||
|
@ -1071,8 +1071,8 @@ PyObject_GetAttrString(PyObject *v, const char *name)
|
|||
{
|
||||
PyObject *w, *res;
|
||||
|
||||
if (Py_Type(v)->tp_getattr != NULL)
|
||||
return (*Py_Type(v)->tp_getattr)(v, (char*)name);
|
||||
if (Py_TYPE(v)->tp_getattr != NULL)
|
||||
return (*Py_TYPE(v)->tp_getattr)(v, (char*)name);
|
||||
w = PyString_InternFromString(name);
|
||||
if (w == NULL)
|
||||
return NULL;
|
||||
|
@ -1099,8 +1099,8 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
|
|||
PyObject *s;
|
||||
int res;
|
||||
|
||||
if (Py_Type(v)->tp_setattr != NULL)
|
||||
return (*Py_Type(v)->tp_setattr)(v, (char*)name, w);
|
||||
if (Py_TYPE(v)->tp_setattr != NULL)
|
||||
return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w);
|
||||
s = PyString_InternFromString(name);
|
||||
if (s == NULL)
|
||||
return -1;
|
||||
|
@ -1112,7 +1112,7 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
|
|||
PyObject *
|
||||
PyObject_GetAttr(PyObject *v, PyObject *name)
|
||||
{
|
||||
PyTypeObject *tp = Py_Type(v);
|
||||
PyTypeObject *tp = Py_TYPE(v);
|
||||
|
||||
if (!PyString_Check(name)) {
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
@ -1129,7 +1129,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
|
|||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"attribute name must be string, not '%.200s'",
|
||||
Py_Type(name)->tp_name);
|
||||
Py_TYPE(name)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1158,7 +1158,7 @@ PyObject_HasAttr(PyObject *v, PyObject *name)
|
|||
int
|
||||
PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
||||
{
|
||||
PyTypeObject *tp = Py_Type(v);
|
||||
PyTypeObject *tp = Py_TYPE(v);
|
||||
int err;
|
||||
|
||||
if (!PyString_Check(name)){
|
||||
|
@ -1176,7 +1176,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
|
|||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"attribute name must be string, not '%.200s'",
|
||||
Py_Type(name)->tp_name);
|
||||
Py_TYPE(name)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1218,7 +1218,7 @@ PyObject **
|
|||
_PyObject_GetDictPtr(PyObject *obj)
|
||||
{
|
||||
Py_ssize_t dictoffset;
|
||||
PyTypeObject *tp = Py_Type(obj);
|
||||
PyTypeObject *tp = Py_TYPE(obj);
|
||||
|
||||
if (!(tp->tp_flags & Py_TPFLAGS_HAVE_CLASS))
|
||||
return NULL;
|
||||
|
@ -1253,7 +1253,7 @@ PyObject_SelfIter(PyObject *obj)
|
|||
PyObject *
|
||||
PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
||||
{
|
||||
PyTypeObject *tp = Py_Type(obj);
|
||||
PyTypeObject *tp = Py_TYPE(obj);
|
||||
PyObject *descr = NULL;
|
||||
PyObject *res = NULL;
|
||||
descrgetfunc f;
|
||||
|
@ -1275,7 +1275,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
|||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"attribute name must be string, not '%.200s'",
|
||||
Py_Type(name)->tp_name);
|
||||
Py_TYPE(name)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1355,7 +1355,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
|||
}
|
||||
|
||||
if (f != NULL) {
|
||||
res = f(descr, obj, (PyObject *)Py_Type(obj));
|
||||
res = f(descr, obj, (PyObject *)Py_TYPE(obj));
|
||||
Py_DECREF(descr);
|
||||
goto done;
|
||||
}
|
||||
|
@ -1377,7 +1377,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
|
|||
int
|
||||
PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
|
||||
{
|
||||
PyTypeObject *tp = Py_Type(obj);
|
||||
PyTypeObject *tp = Py_TYPE(obj);
|
||||
PyObject *descr;
|
||||
descrsetfunc f;
|
||||
PyObject **dictptr;
|
||||
|
@ -1398,7 +1398,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
|
|||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"attribute name must be string, not '%.200s'",
|
||||
Py_Type(name)->tp_name);
|
||||
Py_TYPE(name)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1692,7 +1692,7 @@ _dir_locals(void)
|
|||
if (!PyList_Check(names)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"dir(): expected keys() of locals to be a list, "
|
||||
"not '%.200s'", Py_Type(names)->tp_name);
|
||||
"not '%.200s'", Py_TYPE(names)->tp_name);
|
||||
Py_DECREF(names);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1827,7 +1827,7 @@ _dir_object(PyObject *obj)
|
|||
if (!PyList_Check(result)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__dir__() must return a list, not %.200s",
|
||||
Py_Type(result)->tp_name);
|
||||
Py_TYPE(result)->tp_name);
|
||||
Py_DECREF(result);
|
||||
result = NULL;
|
||||
}
|
||||
|
@ -2006,7 +2006,7 @@ _Py_ForgetReference(register PyObject *op)
|
|||
void
|
||||
_Py_Dealloc(PyObject *op)
|
||||
{
|
||||
destructor dealloc = Py_Type(op)->tp_dealloc;
|
||||
destructor dealloc = Py_TYPE(op)->tp_dealloc;
|
||||
_Py_ForgetReference(op);
|
||||
(*dealloc)(op);
|
||||
}
|
||||
|
@ -2037,7 +2037,7 @@ _Py_PrintReferenceAddresses(FILE *fp)
|
|||
fprintf(fp, "Remaining object addresses:\n");
|
||||
for (op = refchain._ob_next; op != &refchain; op = op->_ob_next)
|
||||
fprintf(fp, "%p [%" PY_FORMAT_SIZE_T "d] %s\n", op,
|
||||
op->ob_refcnt, Py_Type(op)->tp_name);
|
||||
op->ob_refcnt, Py_TYPE(op)->tp_name);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
|
@ -2055,7 +2055,7 @@ _Py_GetObjects(PyObject *self, PyObject *args)
|
|||
return NULL;
|
||||
for (i = 0; (n == 0 || i < n) && op != &refchain; i++) {
|
||||
while (op == self || op == args || op == res || op == t ||
|
||||
(t != NULL && Py_Type(op) != (PyTypeObject *) t)) {
|
||||
(t != NULL && Py_TYPE(op) != (PyTypeObject *) t)) {
|
||||
op = op->_ob_next;
|
||||
if (op == &refchain)
|
||||
return res;
|
||||
|
@ -2198,7 +2198,7 @@ _PyTrash_destroy_chain(void)
|
|||
{
|
||||
while (_PyTrash_delete_later) {
|
||||
PyObject *op = _PyTrash_delete_later;
|
||||
destructor dealloc = Py_Type(op)->tp_dealloc;
|
||||
destructor dealloc = Py_TYPE(op)->tp_dealloc;
|
||||
|
||||
_PyTrash_delete_later =
|
||||
(PyObject*) _Py_AS_GC(op)->gc.gc_prev;
|
||||
|
|
|
@ -561,7 +561,7 @@ set_dealloc(PySetObject *so)
|
|||
if (num_free_sets < MAXFREESETS && PyAnySet_CheckExact(so))
|
||||
free_sets[num_free_sets++] = so;
|
||||
else
|
||||
Py_Type(so)->tp_free(so);
|
||||
Py_TYPE(so)->tp_free(so);
|
||||
Py_TRASHCAN_SAFE_END(so)
|
||||
}
|
||||
|
||||
|
@ -987,7 +987,7 @@ make_new_set(PyTypeObject *type, PyObject *iterable)
|
|||
(type == &PySet_Type || type == &PyFrozenSet_Type)) {
|
||||
so = free_sets[--num_free_sets];
|
||||
assert (so != NULL && PyAnySet_CheckExact(so));
|
||||
Py_Type(so) = type;
|
||||
Py_TYPE(so) = type;
|
||||
_Py_NewReference((PyObject *)so);
|
||||
EMPTY_TO_MINSIZE(so);
|
||||
PyObject_GC_Track(so);
|
||||
|
@ -1113,8 +1113,8 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
|
|||
memcpy(b->smalltable, tab, sizeof(tab));
|
||||
}
|
||||
|
||||
if (PyType_IsSubtype(Py_Type(a), &PyFrozenSet_Type) &&
|
||||
PyType_IsSubtype(Py_Type(b), &PyFrozenSet_Type)) {
|
||||
if (PyType_IsSubtype(Py_TYPE(a), &PyFrozenSet_Type) &&
|
||||
PyType_IsSubtype(Py_TYPE(b), &PyFrozenSet_Type)) {
|
||||
h = a->hash; a->hash = b->hash; b->hash = h;
|
||||
} else {
|
||||
a->hash = -1;
|
||||
|
@ -1125,7 +1125,7 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
|
|||
static PyObject *
|
||||
set_copy(PySetObject *so)
|
||||
{
|
||||
return make_new_set(Py_Type(so), (PyObject *)so);
|
||||
return make_new_set(Py_TYPE(so), (PyObject *)so);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1203,7 +1203,7 @@ set_intersection(PySetObject *so, PyObject *other)
|
|||
if ((PyObject *)so == other)
|
||||
return set_copy(so);
|
||||
|
||||
result = (PySetObject *)make_new_set(Py_Type(so), NULL);
|
||||
result = (PySetObject *)make_new_set(Py_TYPE(so), NULL);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -1457,7 +1457,7 @@ set_difference(PySetObject *so, PyObject *other)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
result = make_new_set(Py_Type(so), NULL);
|
||||
result = make_new_set(Py_TYPE(so), NULL);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -1558,7 +1558,7 @@ set_symmetric_difference_update(PySetObject *so, PyObject *other)
|
|||
Py_INCREF(other);
|
||||
otherset = (PySetObject *)other;
|
||||
} else {
|
||||
otherset = (PySetObject *)make_new_set(Py_Type(so), other);
|
||||
otherset = (PySetObject *)make_new_set(Py_TYPE(so), other);
|
||||
if (otherset == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1589,7 +1589,7 @@ set_symmetric_difference(PySetObject *so, PyObject *other)
|
|||
PyObject *rv;
|
||||
PySetObject *otherset;
|
||||
|
||||
otherset = (PySetObject *)make_new_set(Py_Type(so), other);
|
||||
otherset = (PySetObject *)make_new_set(Py_TYPE(so), other);
|
||||
if (otherset == NULL)
|
||||
return NULL;
|
||||
rv = set_symmetric_difference_update(otherset, (PyObject *)so);
|
||||
|
@ -1856,7 +1856,7 @@ set_reduce(PySetObject *so)
|
|||
dict = Py_None;
|
||||
Py_INCREF(dict);
|
||||
}
|
||||
result = PyTuple_Pack(3, Py_Type(so), args, dict);
|
||||
result = PyTuple_Pack(3, Py_TYPE(so), args, dict);
|
||||
done:
|
||||
Py_XDECREF(args);
|
||||
Py_XDECREF(keys);
|
||||
|
@ -1873,7 +1873,7 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
|
|||
|
||||
if (!PyAnySet_Check(self))
|
||||
return -1;
|
||||
if (!PyArg_UnpackTuple(args, Py_Type(self)->tp_name, 0, 1, &iterable))
|
||||
if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
|
||||
return -1;
|
||||
set_clear_internal(self);
|
||||
self->hash = -1;
|
||||
|
@ -2168,7 +2168,7 @@ PySet_Size(PyObject *anyset)
|
|||
int
|
||||
PySet_Clear(PyObject *set)
|
||||
{
|
||||
if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
|
||||
if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
|
@ -2188,7 +2188,7 @@ PySet_Contains(PyObject *anyset, PyObject *key)
|
|||
int
|
||||
PySet_Discard(PyObject *set, PyObject *key)
|
||||
{
|
||||
if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
|
||||
if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
|
@ -2198,7 +2198,7 @@ PySet_Discard(PyObject *set, PyObject *key)
|
|||
int
|
||||
PySet_Add(PyObject *set, PyObject *key)
|
||||
{
|
||||
if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
|
||||
if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
|
@ -2239,7 +2239,7 @@ _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash)
|
|||
PyObject *
|
||||
PySet_Pop(PyObject *set)
|
||||
{
|
||||
if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
|
||||
if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
|
||||
PyErr_BadInternalCall();
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2249,7 +2249,7 @@ PySet_Pop(PyObject *set)
|
|||
int
|
||||
_PySet_Update(PyObject *set, PyObject *iterable)
|
||||
{
|
||||
if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) {
|
||||
if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue