Merged revisions 56467-56482 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ................ r56477 | martin.v.loewis | 2007-07-21 09:04:38 +0200 (Sa, 21 Jul 2007) | 11 lines Merged revisions 56466-56476 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r56476 | martin.v.loewis | 2007-07-21 08:55:02 +0200 (Sa, 21 Jul 2007) | 4 lines PEP 3123: Provide forward compatibility with Python 3.0, while keeping backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT. ........ ................ r56478 | martin.v.loewis | 2007-07-21 09:47:23 +0200 (Sa, 21 Jul 2007) | 2 lines PEP 3123: Use proper C inheritance for PyObject. ................ r56479 | martin.v.loewis | 2007-07-21 10:06:55 +0200 (Sa, 21 Jul 2007) | 3 lines Add longintrepr.h to Python.h, so that the compiler can see that PyFalse is really some kind of PyObject*. ................ r56480 | martin.v.loewis | 2007-07-21 10:47:18 +0200 (Sa, 21 Jul 2007) | 2 lines Qualify SHIFT, MASK, BASE. ................ r56482 | martin.v.loewis | 2007-07-21 19:10:57 +0200 (Sa, 21 Jul 2007) | 2 lines Correctly refer to _ob_next. ................
This commit is contained in:
parent
b972a78e17
commit
9f2e346911
|
@ -67,8 +67,9 @@
|
|||
#include "bytesobject.h"
|
||||
#include "unicodeobject.h"
|
||||
#include "intobject.h"
|
||||
#include "boolobject.h"
|
||||
#include "longobject.h"
|
||||
#include "longintrepr.h"
|
||||
#include "boolobject.h"
|
||||
#include "floatobject.h"
|
||||
#ifndef WITHOUT_COMPLEX
|
||||
#include "complexobject.h"
|
||||
|
|
|
@ -986,7 +986,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
|
|||
*/
|
||||
|
||||
#define PySequence_ITEM(o, i)\
|
||||
( o->ob_type->tp_as_sequence->sq_item(o, i) )
|
||||
( Py_Type(o)->tp_as_sequence->sq_item(o, i) )
|
||||
/* Assume tp_as_sequence and sq_item exist and that i does not
|
||||
need to be corrected for a negative index
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||
|
||||
#define PyBool_Check(x) ((x)->ob_type == &PyBool_Type)
|
||||
#define PyBool_Check(x) (Py_Type(x) == &PyBool_Type)
|
||||
|
||||
/* Py_False and Py_True are the only two bools in existence.
|
||||
Don't forget to apply Py_INCREF() when returning either!!! */
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
|
||||
|
||||
#define PyBuffer_Check(op) ((op)->ob_type == &PyBuffer_Type)
|
||||
#define PyBuffer_Check(op) (Py_Type(op) == &PyBuffer_Type)
|
||||
|
||||
#define Py_END_OF_BUFFER (-1)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ PyAPI_DATA(PyTypeObject) PyBytes_Type;
|
|||
|
||||
/* Type check macros */
|
||||
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)
|
||||
#define PyBytes_CheckExact(self) ((self)->ob_type == &PyBytes_Type)
|
||||
#define PyBytes_CheckExact(self) (Py_Type(self) == &PyBytes_Type)
|
||||
|
||||
/* Direct API functions */
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
|
||||
|
|
|
@ -60,9 +60,9 @@ static struct PycStringIO_CAPI {
|
|||
|
||||
/* These can be used to test if you have one */
|
||||
#define PycStringIO_InputCheck(O) \
|
||||
((O)->ob_type==PycStringIO->InputType)
|
||||
(Py_Type(O)==PycStringIO->InputType)
|
||||
#define PycStringIO_OutputCheck(O) \
|
||||
((O)->ob_type==PycStringIO->OutputType)
|
||||
(Py_Type(O)==PycStringIO->OutputType)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCell_Type;
|
||||
|
||||
#define PyCell_Check(op) ((op)->ob_type == &PyCell_Type)
|
||||
#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||
|
|
|
@ -16,7 +16,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCObject_Type;
|
||||
|
||||
#define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type)
|
||||
#define PyCObject_Check(op) (Py_Type(op) == &PyCObject_Type)
|
||||
|
||||
/* Create a PyCObject from a pointer to a C object and an optional
|
||||
destructor function. If the second argument is non-null, then it
|
||||
|
|
|
@ -59,7 +59,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCode_Type;
|
||||
|
||||
#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
|
||||
#define PyCode_Check(op) (Py_Type(op) == &PyCode_Type)
|
||||
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
|
||||
|
||||
/* Public interface */
|
||||
|
@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
|
|||
|
||||
/* for internal use only */
|
||||
#define _PyCode_GETCODEPTR(co, pp) \
|
||||
((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
|
||||
((*Py_Type((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
|
||||
((co)->co_code, 0, (void **)(pp)))
|
||||
|
||||
typedef struct _addr_pair {
|
||||
|
|
|
@ -43,7 +43,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
||||
|
||||
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) ((op)->ob_type == &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) (Py_Type(op) == &PyComplex_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
|
||||
|
|
|
@ -166,19 +166,19 @@ typedef struct {
|
|||
|
||||
/* Macros for type checking when building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
|
||||
#define PyDate_CheckExact(op) ((op)->ob_type == &PyDateTime_DateType)
|
||||
#define PyDate_CheckExact(op) (Py_Type(op) == &PyDateTime_DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) ((op)->ob_type == &PyDateTime_DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
|
||||
#define PyTime_CheckExact(op) ((op)->ob_type == &PyDateTime_TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
|
||||
#define PyDelta_CheckExact(op) ((op)->ob_type == &PyDateTime_DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) ((op)->ob_type == &PyDateTime_TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_Type(op) == &PyDateTime_TZInfoType)
|
||||
|
||||
#else
|
||||
|
||||
|
@ -198,19 +198,19 @@ static PyDateTime_CAPI *PyDateTimeAPI;
|
|||
|
||||
/* Macros for type checking when not building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
|
||||
#define PyDate_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DateType)
|
||||
#define PyDate_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TZInfoType)
|
||||
|
||||
/* Macros for accessing constructors in a simplified fashion. */
|
||||
#define PyDate_FromDate(year, month, day) \
|
||||
|
|
|
@ -77,7 +77,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
|
|||
struct PyGetSetDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
|
||||
struct wrapperbase *, void *);
|
||||
#define PyDescr_IsData(d) ((d)->ob_type->tp_descr_set != NULL)
|
||||
#define PyDescr_IsData(d) (Py_Type(d)->tp_descr_set != NULL)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
||||
|
|
|
@ -91,8 +91,8 @@ struct _dictobject {
|
|||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) ((op)->ob_type == &PyDict_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) (Py_Type(op) == &PyDict_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
|
|
|
@ -19,7 +19,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||
|
||||
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) ((op)->ob_type == &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type)
|
||||
|
||||
/* Return Python float from string PyObject. */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef struct _frame {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
||||
|
||||
#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
|
||||
#define PyFrame_Check(op) (Py_Type(op) == &PyFrame_Type)
|
||||
|
||||
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyFunction_Type;
|
||||
|
||||
#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
|
||||
#define PyFunction_Check(op) (Py_Type(op) == &PyFunction_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
||||
|
||||
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) (Py_Type(op) == &PyGen_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
|
||||
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
|
||||
|
|
|
@ -7,13 +7,13 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
|
||||
|
||||
#define PySeqIter_Check(op) ((op)->ob_type == &PySeqIter_Type)
|
||||
#define PySeqIter_Check(op) (Py_Type(op) == &PySeqIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
|
||||
|
||||
#define PyCallIter_Check(op) ((op)->ob_type == &PyCallIter_Type)
|
||||
#define PyCallIter_Check(op) (Py_Type(op) == &PyCallIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyList_Type;
|
||||
|
||||
#define PyList_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_LIST_SUBCLASS)
|
||||
#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LIST_SUBCLASS)
|
||||
#define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
|
||||
|
@ -60,7 +60,7 @@ PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
|
|||
/* Macro, trading safety for speed */
|
||||
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
|
||||
#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
|
||||
#define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
|
||||
#define PyList_GET_SIZE(op) Py_Size(op)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ typedef unsigned int wdigit; /* digit widened to parameter size */
|
|||
typedef unsigned BASE_TWODIGITS_TYPE twodigits;
|
||||
typedef BASE_TWODIGITS_TYPE stwodigits; /* signed variant of twodigits */
|
||||
|
||||
#define SHIFT 15
|
||||
#define BASE ((digit)1 << SHIFT)
|
||||
#define MASK ((int)(BASE - 1))
|
||||
#define PyLong_SHIFT 15
|
||||
#define PyLong_BASE ((digit)1 << PyLong_SHIFT)
|
||||
#define PyLong_MASK ((int)(PyLong_BASE - 1))
|
||||
|
||||
#if SHIFT % 5 != 0
|
||||
#if PyLong_SHIFT % 5 != 0
|
||||
#error "longobject.c requires that SHIFT be divisible by 5"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
|
|||
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||
|
||||
#define PyLong_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_LONG_SUBCLASS)
|
||||
#define PyLong_CheckExact(op) ((op)->ob_type == &PyLong_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||
#define PyLong_CheckExact(op) (Py_Type(op) == &PyLong_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
|
||||
|
||||
#define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type)
|
||||
#define PyCFunction_Check(op) (Py_Type(op) == &PyCFunction_Type)
|
||||
|
||||
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
|
||||
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
|
||||
|
|
|
@ -10,7 +10,7 @@ extern "C" {
|
|||
PyAPI_DATA(PyTypeObject) PyModule_Type;
|
||||
|
||||
#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) ((op)->ob_type == &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) (Py_Type(op) == &PyModule_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyModule_New(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
|
||||
|
|
|
@ -75,14 +75,14 @@ whose size is determined when the object is allocated.
|
|||
#endif
|
||||
|
||||
/* PyObject_HEAD defines the initial segment of every PyObject. */
|
||||
#define PyObject_HEAD \
|
||||
_PyObject_HEAD_EXTRA \
|
||||
Py_ssize_t ob_refcnt; \
|
||||
struct _typeobject *ob_type;
|
||||
#define PyObject_HEAD PyObject ob_base;
|
||||
|
||||
#define PyObject_HEAD_INIT(type) \
|
||||
_PyObject_EXTRA_INIT \
|
||||
1, type,
|
||||
{ _PyObject_EXTRA_INIT \
|
||||
1, type },
|
||||
|
||||
#define PyVarObject_HEAD_INIT(type, size) \
|
||||
{ PyObject_HEAD_INIT(type) size },
|
||||
|
||||
/* PyObject_VAR_HEAD defines the initial segment of all variable-size
|
||||
* container objects. These end with a declaration of an array with 1
|
||||
|
@ -90,9 +90,7 @@ whose size is determined when the object is allocated.
|
|||
* has room for ob_size elements. Note that ob_size is an element count,
|
||||
* not necessarily a byte count.
|
||||
*/
|
||||
#define PyObject_VAR_HEAD \
|
||||
PyObject_HEAD \
|
||||
Py_ssize_t ob_size; /* Number of items in variable part */
|
||||
#define PyObject_VAR_HEAD PyVarObject ob_base;
|
||||
#define Py_INVALID_SIZE (Py_ssize_t)-1
|
||||
|
||||
/* Nothing is actually declared to be a PyObject, but every pointer to
|
||||
|
@ -101,13 +99,19 @@ whose size is determined when the object is allocated.
|
|||
* in addition, be cast to PyVarObject*.
|
||||
*/
|
||||
typedef struct _object {
|
||||
PyObject_HEAD
|
||||
_PyObject_HEAD_EXTRA
|
||||
Py_ssize_t ob_refcnt;
|
||||
struct _typeobject *ob_type;
|
||||
} PyObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
PyObject ob_base;
|
||||
Py_ssize_t ob_size; /* Number of items in variable part */
|
||||
} PyVarObject;
|
||||
|
||||
#define Py_Refcnt(ob) (((PyObject*)(ob))->ob_refcnt)
|
||||
#define Py_Type(ob) (((PyObject*)(ob))->ob_type)
|
||||
#define Py_Size(ob) (((PyVarObject*)(ob))->ob_size)
|
||||
|
||||
/*
|
||||
Type objects contain a string containing the type name (to help somewhat
|
||||
|
@ -346,21 +350,21 @@ typedef struct _heaptypeobject {
|
|||
|
||||
/* access macro to the members which are floating "behind" the object */
|
||||
#define PyHeapType_GET_MEMBERS(etype) \
|
||||
((PyMemberDef *)(((char *)etype) + (etype)->ht_type.ob_type->tp_basicsize))
|
||||
((PyMemberDef *)(((char *)etype) + Py_Type(etype)->tp_basicsize))
|
||||
|
||||
|
||||
/* Generic type check */
|
||||
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
|
||||
#define PyObject_TypeCheck(ob, tp) \
|
||||
((ob)->ob_type == (tp) || PyType_IsSubtype((ob)->ob_type, (tp)))
|
||||
(Py_Type(ob) == (tp) || PyType_IsSubtype(Py_Type(ob), (tp)))
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
|
||||
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
|
||||
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
|
||||
|
||||
#define PyType_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_TYPE_SUBCLASS)
|
||||
#define PyType_CheckExact(op) ((op)->ob_type == &PyType_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TYPE_SUBCLASS)
|
||||
#define PyType_CheckExact(op) (Py_Type(op) == &PyType_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
|
||||
|
@ -543,7 +547,7 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
|
|||
#define _Py_DEC_REFTOTAL _Py_RefTotal--
|
||||
#define _Py_REF_DEBUG_COMMA ,
|
||||
#define _Py_CHECK_REFCNT(OP) \
|
||||
{ if ((OP)->ob_refcnt < 0) \
|
||||
{ if (((PyObject*)OP)->ob_refcnt < 0) \
|
||||
_Py_NegativeRefcount(__FILE__, __LINE__, \
|
||||
(PyObject *)(OP)); \
|
||||
}
|
||||
|
@ -557,9 +561,9 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
|
|||
#ifdef COUNT_ALLOCS
|
||||
PyAPI_FUNC(void) inc_count(PyTypeObject *);
|
||||
PyAPI_FUNC(void) dec_count(PyTypeObject *);
|
||||
#define _Py_INC_TPALLOCS(OP) inc_count((OP)->ob_type)
|
||||
#define _Py_INC_TPFREES(OP) dec_count((OP)->ob_type)
|
||||
#define _Py_DEC_TPFREES(OP) (OP)->ob_type->tp_frees--
|
||||
#define _Py_INC_TPALLOCS(OP) inc_count(Py_Type(OP))
|
||||
#define _Py_INC_TPFREES(OP) dec_count(Py_Type(OP))
|
||||
#define _Py_DEC_TPFREES(OP) Py_Type(OP)->tp_frees--
|
||||
#define _Py_COUNT_ALLOCS_COMMA ,
|
||||
#else
|
||||
#define _Py_INC_TPALLOCS(OP)
|
||||
|
@ -584,22 +588,22 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
|
|||
#define _Py_NewReference(op) ( \
|
||||
_Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
(op)->ob_refcnt = 1)
|
||||
Py_Refcnt(op) = 1)
|
||||
|
||||
#define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
|
||||
|
||||
#define _Py_Dealloc(op) ( \
|
||||
_Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
(*(op)->ob_type->tp_dealloc)((PyObject *)(op)))
|
||||
(*Py_Type(op)->tp_dealloc)((PyObject *)(op)))
|
||||
#endif /* !Py_TRACE_REFS */
|
||||
|
||||
#define Py_INCREF(op) ( \
|
||||
_Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
(op)->ob_refcnt++)
|
||||
((PyObject*)(op))->ob_refcnt++)
|
||||
|
||||
#define Py_DECREF(op) \
|
||||
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
|
||||
--(op)->ob_refcnt != 0) \
|
||||
--((PyObject*)(op))->ob_refcnt != 0) \
|
||||
_Py_CHECK_REFCNT(op) \
|
||||
else \
|
||||
_Py_Dealloc((PyObject *)(op))
|
||||
|
|
|
@ -154,9 +154,9 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
|||
/* Macros trading binary compatibility for speed. See also pymem.h.
|
||||
Note that these macros expect non-NULL object pointers.*/
|
||||
#define PyObject_INIT(op, typeobj) \
|
||||
( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
( Py_Type(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
||||
#define PyObject_INIT_VAR(op, typeobj, size) \
|
||||
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
|
||||
( Py_Size(op) = (size), PyObject_INIT((op), (typeobj)) )
|
||||
|
||||
#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize )
|
||||
|
||||
|
@ -231,8 +231,8 @@ PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
|
|||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
||||
|
||||
/* Test if an object has a GC head */
|
||||
#define PyObject_IS_GC(o) (PyType_IS_GC((o)->ob_type) && \
|
||||
((o)->ob_type->tp_is_gc == NULL || (o)->ob_type->tp_is_gc(o)))
|
||||
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_Type(o)) && \
|
||||
(Py_Type(o)->tp_is_gc == NULL || Py_Type(o)->tp_is_gc(o)))
|
||||
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
#define PyObject_GC_Resize(type, op, n) \
|
||||
|
@ -326,7 +326,7 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
|||
#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
|
||||
|
||||
#define PyObject_GET_WEAKREFS_LISTPTR(o) \
|
||||
((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset))
|
||||
((PyObject **) (((char *) (o)) + Py_Type(o)->tp_weaklistoffset))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ typedef struct {
|
|||
WINDOW *win;
|
||||
} PyCursesWindowObject;
|
||||
|
||||
#define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
|
||||
#define PyCursesWindow_Check(v) (Py_Type(v) == &PyCursesWindow_Type)
|
||||
|
||||
#ifdef CURSES_MODULE
|
||||
/* This section is used when compiling _cursesmodule.c */
|
||||
|
|
|
@ -17,7 +17,7 @@ they are represented by a start, stop, and step datamembers.
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PyRange_Type;
|
||||
|
||||
#define PyRange_Check(op) ((op)->ob_type == &PyRange_Type)
|
||||
#define PyRange_Check(op) (Py_Type(op) == &PyRange_Type)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -66,13 +66,13 @@ PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
|
|||
* hash is -1
|
||||
*/
|
||||
|
||||
#define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type)
|
||||
#define PyFrozenSet_CheckExact(ob) (Py_Type(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_CheckExact(ob) \
|
||||
((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type)
|
||||
(Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_Check(ob) \
|
||||
((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type || \
|
||||
PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \
|
||||
PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type))
|
||||
(Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type || \
|
||||
PyType_IsSubtype(Py_Type(ob), &PySet_Type) || \
|
||||
PyType_IsSubtype(Py_Type(ob), &PyFrozenSet_Type))
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySlice_Type;
|
||||
|
||||
#define PySlice_Check(op) ((op)->ob_type == &PySlice_Type)
|
||||
#define PySlice_Check(op) (Py_Type(op) == &PySlice_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
|
||||
PyObject* step);
|
||||
|
|
|
@ -52,8 +52,8 @@ PyAPI_DATA(PyTypeObject) PyBaseString_Type;
|
|||
PyAPI_DATA(PyTypeObject) PyString_Type;
|
||||
|
||||
#define PyString_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_STRING_SUBCLASS)
|
||||
#define PyString_CheckExact(op) ((op)->ob_type == &PyString_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_STRING_SUBCLASS)
|
||||
#define PyString_CheckExact(op) (Py_Type(op) == &PyString_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef struct _symtable_entry {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySTEntry_Type;
|
||||
|
||||
#define PySTEntry_Check(op) ((op)->ob_type == &PySTEntry_Type)
|
||||
#define PySTEntry_Check(op) (Py_Type(op) == &PySTEntry_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
|
|||
|
||||
/* Reveal traceback type so we can typecheck traceback objects */
|
||||
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
|
||||
#define PyTraceBack_Check(v) ((v)->ob_type == &PyTraceBack_Type)
|
||||
#define PyTraceBack_Check(v) (Py_Type(v) == &PyTraceBack_Type)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ typedef struct {
|
|||
PyAPI_DATA(PyTypeObject) PyTuple_Type;
|
||||
|
||||
#define PyTuple_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_TUPLE_SUBCLASS)
|
||||
#define PyTuple_CheckExact(op) ((op)->ob_type == &PyTuple_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TUPLE_SUBCLASS)
|
||||
#define PyTuple_CheckExact(op) (Py_Type(op) == &PyTuple_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
|
||||
|
@ -47,7 +47,7 @@ PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
|
|||
|
||||
/* Macro, trading safety for speed */
|
||||
#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
|
||||
#define PyTuple_GET_SIZE(op) (((PyTupleObject *)(op))->ob_size)
|
||||
#define PyTuple_GET_SIZE(op) Py_Size(op)
|
||||
|
||||
/* Macro, *only* to be used to fill in brand new tuples */
|
||||
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
|
||||
|
|
|
@ -405,8 +405,8 @@ PyAPI_DATA(PyTypeObject) PyUnicode_Type;
|
|||
#define SSTATE_INTERNED_IMMORTAL 2
|
||||
|
||||
#define PyUnicode_Check(op) \
|
||||
PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_UNICODE_SUBCLASS)
|
||||
#define PyUnicode_CheckExact(op) ((op)->ob_type == &PyUnicode_Type)
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_UNICODE_SUBCLASS)
|
||||
#define PyUnicode_CheckExact(op) (Py_Type(op) == &PyUnicode_Type)
|
||||
|
||||
/* Fast access macros */
|
||||
#define PyUnicode_GET_SIZE(op) \
|
||||
|
|
|
@ -44,10 +44,10 @@ PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
|||
|
||||
#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckRefExact(op) \
|
||||
((op)->ob_type == &_PyWeakref_RefType)
|
||||
(Py_Type(op) == &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckProxy(op) \
|
||||
(((op)->ob_type == &_PyWeakref_ProxyType) || \
|
||||
((op)->ob_type == &_PyWeakref_CallableProxyType))
|
||||
((Py_Type(op) == &_PyWeakref_ProxyType) || \
|
||||
(Py_Type(op) == &_PyWeakref_CallableProxyType))
|
||||
|
||||
/* This macro calls PyWeakref_CheckRef() last since that can involve a
|
||||
function call; this makes it more likely that the function call
|
||||
|
|
|
@ -26,6 +26,8 @@ TO DO
|
|||
Core and Builtins
|
||||
-----------------
|
||||
|
||||
- PEP 3123: Use proper C inheritance for PyObject.
|
||||
|
||||
- Removed the __oct__ and __hex__ special methods and added a bin()
|
||||
builtin function.
|
||||
|
||||
|
|
|
@ -300,13 +300,13 @@ static PyTypeObject DBSequence_Type;
|
|||
|
||||
static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type;
|
||||
|
||||
#define DBObject_Check(v) ((v)->ob_type == &DB_Type)
|
||||
#define DBCursorObject_Check(v) ((v)->ob_type == &DBCursor_Type)
|
||||
#define DBEnvObject_Check(v) ((v)->ob_type == &DBEnv_Type)
|
||||
#define DBTxnObject_Check(v) ((v)->ob_type == &DBTxn_Type)
|
||||
#define DBLockObject_Check(v) ((v)->ob_type == &DBLock_Type)
|
||||
#define DBObject_Check(v) (Py_Type(v) == &DB_Type)
|
||||
#define DBCursorObject_Check(v) (Py_Type(v) == &DBCursor_Type)
|
||||
#define DBEnvObject_Check(v) (Py_Type(v) == &DBEnv_Type)
|
||||
#define DBTxnObject_Check(v) (Py_Type(v) == &DBTxn_Type)
|
||||
#define DBLockObject_Check(v) (Py_Type(v) == &DBLock_Type)
|
||||
#if (DBVER >= 43)
|
||||
#define DBSequenceObject_Check(v) ((v)->ob_type == &DBSequence_Type)
|
||||
#define DBSequenceObject_Check(v) (Py_Type(v) == &DBSequence_Type)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -461,7 +461,7 @@ make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags)
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"String or Integer object expected for key, %s found",
|
||||
keyobj->ob_type->tp_name);
|
||||
Py_Type(keyobj)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ static int makeDBError(int err)
|
|||
static void makeTypeError(char* expected, PyObject* found)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.",
|
||||
expected, found->ob_type->tp_name);
|
||||
expected, Py_Type(found)->tp_name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5369,8 +5369,7 @@ DBSequence_getattr(DBSequenceObject* self, char *name)
|
|||
#endif
|
||||
|
||||
static PyTypeObject DB_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"DB", /*tp_name*/
|
||||
sizeof(DBObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -5402,8 +5401,7 @@ static PyTypeObject DB_Type = {
|
|||
|
||||
|
||||
static PyTypeObject DBCursor_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"DBCursor", /*tp_name*/
|
||||
sizeof(DBCursorObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -5435,8 +5433,7 @@ static PyTypeObject DBCursor_Type = {
|
|||
|
||||
|
||||
static PyTypeObject DBEnv_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"DBEnv", /*tp_name*/
|
||||
sizeof(DBEnvObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -5467,8 +5464,7 @@ static PyTypeObject DBEnv_Type = {
|
|||
};
|
||||
|
||||
static PyTypeObject DBTxn_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"DBTxn", /*tp_name*/
|
||||
sizeof(DBTxnObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -5500,8 +5496,7 @@ static PyTypeObject DBTxn_Type = {
|
|||
|
||||
|
||||
static PyTypeObject DBLock_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"DBLock", /*tp_name*/
|
||||
sizeof(DBLockObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -5533,8 +5528,7 @@ static PyTypeObject DBLock_Type = {
|
|||
|
||||
#if (DBVER >= 43)
|
||||
static PyTypeObject DBSequence_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"DBSequence", /*tp_name*/
|
||||
sizeof(DBSequenceObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -5666,13 +5660,13 @@ PyMODINIT_FUNC init_bsddb(void)
|
|||
|
||||
/* Initialize the type of the new type objects here; doing it here
|
||||
is required for portability to Windows without requiring C++. */
|
||||
DB_Type.ob_type = &PyType_Type;
|
||||
DBCursor_Type.ob_type = &PyType_Type;
|
||||
DBEnv_Type.ob_type = &PyType_Type;
|
||||
DBTxn_Type.ob_type = &PyType_Type;
|
||||
DBLock_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&DB_Type) = &PyType_Type;
|
||||
Py_Type(&DBCursor_Type) = &PyType_Type;
|
||||
Py_Type(&DBEnv_Type) = &PyType_Type;
|
||||
Py_Type(&DBTxn_Type) = &PyType_Type;
|
||||
Py_Type(&DBLock_Type) = &PyType_Type;
|
||||
#if (DBVER >= 43)
|
||||
DBSequence_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&DBSequence_Type) = &PyType_Type;
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -544,7 +544,7 @@ deque_dealloc(dequeobject *deque)
|
|||
}
|
||||
deque->leftblock = NULL;
|
||||
deque->rightblock = NULL;
|
||||
deque->ob_type->tp_free(deque);
|
||||
Py_Type(deque)->tp_free(deque);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -579,7 +579,7 @@ deque_nohash(PyObject *self)
|
|||
static PyObject *
|
||||
deque_copy(PyObject *deque)
|
||||
{
|
||||
return PyObject_CallFunctionObjArgs((PyObject *)(deque->ob_type),
|
||||
return PyObject_CallFunctionObjArgs((PyObject *)(Py_Type(deque)),
|
||||
deque, NULL);
|
||||
}
|
||||
|
||||
|
@ -601,7 +601,7 @@ deque_reduce(dequeobject *deque)
|
|||
Py_DECREF(dict);
|
||||
return NULL;
|
||||
}
|
||||
result = Py_BuildValue("O()ON", deque->ob_type, dict, it);
|
||||
result = Py_BuildValue("O()ON", Py_Type(deque), dict, it);
|
||||
Py_DECREF(dict);
|
||||
return result;
|
||||
}
|
||||
|
@ -818,8 +818,7 @@ PyDoc_STRVAR(deque_doc,
|
|||
Build an ordered collection accessible from endpoints only.");
|
||||
|
||||
static PyTypeObject deque_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"collections.deque", /* tp_name */
|
||||
sizeof(dequeobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -896,7 +895,7 @@ static void
|
|||
dequeiter_dealloc(dequeiterobject *dio)
|
||||
{
|
||||
Py_XDECREF(dio->deque);
|
||||
dio->ob_type->tp_free(dio);
|
||||
Py_Type(dio)->tp_free(dio);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -941,8 +940,7 @@ static PyMethodDef dequeiter_methods[] = {
|
|||
};
|
||||
|
||||
PyTypeObject dequeiter_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"deque_iterator", /* tp_name */
|
||||
sizeof(dequeiterobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1024,8 +1022,7 @@ dequereviter_next(dequeiterobject *it)
|
|||
}
|
||||
|
||||
PyTypeObject dequereviter_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"deque_reverse_iterator", /* tp_name */
|
||||
sizeof(dequeiterobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1106,7 +1103,7 @@ defdict_copy(defdictobject *dd)
|
|||
whose class constructor has the same signature. Subclasses that
|
||||
define a different constructor signature must override copy().
|
||||
*/
|
||||
return PyObject_CallFunctionObjArgs((PyObject *)dd->dict.ob_type,
|
||||
return PyObject_CallFunctionObjArgs(Py_Type(dd),
|
||||
dd->default_factory, dd, NULL);
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1146,7 @@ defdict_reduce(defdictobject *dd)
|
|||
Py_DECREF(args);
|
||||
return NULL;
|
||||
}
|
||||
result = PyTuple_Pack(5, dd->dict.ob_type, args,
|
||||
result = PyTuple_Pack(5, Py_Type(dd), args,
|
||||
Py_None, Py_None, items);
|
||||
Py_DECREF(items);
|
||||
Py_DECREF(args);
|
||||
|
@ -1274,8 +1271,7 @@ A defaultdict compares equal to a dict with the same items.\n\
|
|||
#define DEFERRED_ADDRESS(ADDR) 0
|
||||
|
||||
static PyTypeObject defdict_type = {
|
||||
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
|
||||
"collections.defaultdict", /* tp_name */
|
||||
sizeof(defdictobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -125,7 +125,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Reader_Type;
|
||||
|
||||
#define ReaderObject_Check(v) ((v)->ob_type == &Reader_Type)
|
||||
#define ReaderObject_Check(v) (Py_Type(v) == &Reader_Type)
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
|
@ -310,7 +310,7 @@ static void
|
|||
Dialect_dealloc(DialectObj *self)
|
||||
{
|
||||
Py_XDECREF(self->lineterminator);
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static char *dialect_kws[] = {
|
||||
|
@ -460,8 +460,7 @@ PyDoc_STRVAR(Dialect_Type_doc,
|
|||
"The Dialect type records CSV parsing and generation options.\n");
|
||||
|
||||
static PyTypeObject Dialect_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_csv.Dialect", /* tp_name */
|
||||
sizeof(DialectObj), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -869,8 +868,7 @@ static struct PyMemberDef Reader_memberlist[] = {
|
|||
|
||||
|
||||
static PyTypeObject Reader_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_csv.reader", /*tp_name*/
|
||||
sizeof(ReaderObj), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -1280,8 +1278,7 @@ PyDoc_STRVAR(Writer_Type_doc,
|
|||
);
|
||||
|
||||
static PyTypeObject Writer_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_csv.writer", /*tp_name*/
|
||||
sizeof(WriterObj), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
|
@ -328,7 +328,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
|
|||
Py_INCREF(value);
|
||||
return value;
|
||||
}
|
||||
ob_name = (ob) ? ob->ob_type->tp_name : "???";
|
||||
ob_name = (ob) ? Py_Type(ob)->tp_name : "???";
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instance instead of pointer to %s",
|
||||
((PyTypeObject *)type)->tp_name, ob_name);
|
||||
|
@ -344,7 +344,7 @@ CDataType_from_param(PyObject *type, PyObject *value)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instance instead of %s",
|
||||
((PyTypeObject *)type)->tp_name,
|
||||
value->ob_type->tp_name);
|
||||
Py_Type(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -427,8 +427,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value)
|
|||
|
||||
|
||||
PyTypeObject StructType_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.StructType", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -470,8 +469,7 @@ PyTypeObject StructType_Type = {
|
|||
};
|
||||
|
||||
static PyTypeObject UnionType_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.UnionType", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -685,8 +683,7 @@ static PyMethodDef PointerType_methods[] = {
|
|||
};
|
||||
|
||||
PyTypeObject PointerType_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.PointerType", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -743,7 +740,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
|
|||
char *ptr;
|
||||
Py_ssize_t size;
|
||||
if (PyBuffer_Check(value)) {
|
||||
size = value->ob_type->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
|
||||
size = Py_Type(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
|
||||
if (size < 0)
|
||||
return -1;
|
||||
} else if (-1 == PyString_AsStringAndSize(value, &ptr, &size)) {
|
||||
|
@ -792,7 +789,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
|
|||
} else if (!PyBytes_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"str/bytes expected instead of %s instance",
|
||||
value->ob_type->tp_name);
|
||||
Py_Type(value)->tp_name);
|
||||
return -1;
|
||||
} else
|
||||
Py_INCREF(value);
|
||||
|
@ -847,7 +844,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
|
|||
} else if (!PyUnicode_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unicode string expected instead of %s instance",
|
||||
value->ob_type->tp_name);
|
||||
Py_Type(value)->tp_name);
|
||||
return -1;
|
||||
} else
|
||||
Py_INCREF(value);
|
||||
|
@ -1043,8 +1040,7 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
|
||||
PyTypeObject ArrayType_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.ArrayType", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1682,8 +1678,7 @@ static PyMethodDef SimpleType_methods[] = {
|
|||
};
|
||||
|
||||
PyTypeObject SimpleType_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.SimpleType", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1893,8 +1888,7 @@ CFuncPtrType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
|
||||
PyTypeObject CFuncPtrType_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.CFuncPtrType", /* tp_name */
|
||||
0, /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2062,7 +2056,7 @@ static void
|
|||
CData_dealloc(PyObject *self)
|
||||
{
|
||||
CData_clear((CDataObject *)self);
|
||||
self->ob_type->tp_free(self);
|
||||
Py_Type(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyMemberDef CData_members[] = {
|
||||
|
@ -2129,8 +2123,7 @@ static PyMethodDef CData_methods[] = {
|
|||
};
|
||||
|
||||
PyTypeObject CData_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes._CData",
|
||||
sizeof(CDataObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2336,7 +2329,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instance, got %s",
|
||||
((PyTypeObject *)type)->tp_name,
|
||||
value->ob_type->tp_name);
|
||||
Py_Type(value)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2367,7 +2360,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
|||
if (p1->proto != p2->proto) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"incompatible types, %s instance instead of %s instance",
|
||||
value->ob_type->tp_name,
|
||||
Py_Type(value)->tp_name,
|
||||
((PyTypeObject *)type)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2386,7 +2379,7 @@ _CData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
|
|||
}
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"incompatible types, %s instance instead of %s instance",
|
||||
value->ob_type->tp_name,
|
||||
Py_Type(value)->tp_name,
|
||||
((PyTypeObject *)type)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2647,7 +2640,7 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index)
|
|||
Py_SAFE_DOWNCAST(index, Py_ssize_t, int),
|
||||
PyType_Check(arg) ?
|
||||
((PyTypeObject *)arg)->tp_name :
|
||||
arg->ob_type->tp_name);
|
||||
Py_Type(arg)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3429,7 +3422,7 @@ static void
|
|||
CFuncPtr_dealloc(CFuncPtrObject *self)
|
||||
{
|
||||
CFuncPtr_clear(self);
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -3439,17 +3432,16 @@ CFuncPtr_repr(CFuncPtrObject *self)
|
|||
if (self->index)
|
||||
return PyUnicode_FromFormat("<COM method offset %d: %s at %p>",
|
||||
self->index - 0x1000,
|
||||
self->ob_type->tp_name,
|
||||
Py_Type(self)->tp_name,
|
||||
self);
|
||||
#endif
|
||||
return PyUnicode_FromFormat("<%s object at %p>",
|
||||
self->ob_type->tp_name,
|
||||
Py_Type(self)->tp_name,
|
||||
self);
|
||||
}
|
||||
|
||||
PyTypeObject CFuncPtr_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.CFuncPtr",
|
||||
sizeof(CFuncPtrObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3577,8 +3569,7 @@ Struct_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
|
||||
static PyTypeObject Struct_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.Structure",
|
||||
sizeof(CDataObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3620,8 +3611,7 @@ static PyTypeObject Struct_Type = {
|
|||
};
|
||||
|
||||
static PyTypeObject Union_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.Union",
|
||||
sizeof(CDataObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3853,8 +3843,7 @@ static PySequenceMethods Array_as_sequence = {
|
|||
};
|
||||
|
||||
PyTypeObject Array_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.Array",
|
||||
sizeof(CDataObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3999,7 +3988,7 @@ static PyGetSetDef Simple_getsets[] = {
|
|||
static PyObject *
|
||||
Simple_from_outparm(PyObject *self, PyObject *args)
|
||||
{
|
||||
if (IsSimpleSubType((PyObject *)self->ob_type)) {
|
||||
if (IsSimpleSubType((PyObject *)Py_Type(self))) {
|
||||
Py_INCREF(self);
|
||||
return self;
|
||||
}
|
||||
|
@ -4037,9 +4026,9 @@ Simple_repr(CDataObject *self)
|
|||
PyObject *val, *name, *args, *result;
|
||||
static PyObject *format;
|
||||
|
||||
if (self->ob_type->tp_base != &Simple_Type) {
|
||||
if (Py_Type(self)->tp_base != &Simple_Type) {
|
||||
return PyUnicode_FromFormat("<%s object at %p>",
|
||||
self->ob_type->tp_name, self);
|
||||
Py_Type(self)->tp_name, self);
|
||||
}
|
||||
|
||||
if (format == NULL) {
|
||||
|
@ -4070,8 +4059,7 @@ Simple_repr(CDataObject *self)
|
|||
}
|
||||
|
||||
static PyTypeObject Simple_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes._SimpleCData",
|
||||
sizeof(CDataObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -4224,7 +4212,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %s instead of %s",
|
||||
((PyTypeObject *)(stgdict->proto))->tp_name,
|
||||
value->ob_type->tp_name);
|
||||
Py_Type(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -4352,8 +4340,7 @@ static PyNumberMethods Pointer_as_number = {
|
|||
};
|
||||
|
||||
PyTypeObject Pointer_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes._Pointer",
|
||||
sizeof(CDataObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -4531,7 +4518,7 @@ cast_check_pointertype(PyObject *arg)
|
|||
"cast() argument 2 must be a pointer type, not %s",
|
||||
PyType_Check(arg)
|
||||
? ((PyTypeObject *)arg)->tp_name
|
||||
: arg->ob_type->tp_name);
|
||||
: Py_Type(arg)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4658,37 +4645,37 @@ init_ctypes(void)
|
|||
if (PyType_Ready(&CData_Type) < 0)
|
||||
return;
|
||||
|
||||
Struct_Type.ob_type = &StructType_Type;
|
||||
Py_Type(&Struct_Type) = &StructType_Type;
|
||||
Struct_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Struct_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type);
|
||||
|
||||
Union_Type.ob_type = &UnionType_Type;
|
||||
Py_Type(&Union_Type) = &UnionType_Type;
|
||||
Union_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Union_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "Union", (PyObject *)&Union_Type);
|
||||
|
||||
Pointer_Type.ob_type = &PointerType_Type;
|
||||
Py_Type(&Pointer_Type) = &PointerType_Type;
|
||||
Pointer_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Pointer_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "_Pointer", (PyObject *)&Pointer_Type);
|
||||
|
||||
Array_Type.ob_type = &ArrayType_Type;
|
||||
Py_Type(&Array_Type) = &ArrayType_Type;
|
||||
Array_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Array_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "Array", (PyObject *)&Array_Type);
|
||||
|
||||
Simple_Type.ob_type = &SimpleType_Type;
|
||||
Py_Type(&Simple_Type) = &SimpleType_Type;
|
||||
Simple_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&Simple_Type) < 0)
|
||||
return;
|
||||
PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type);
|
||||
|
||||
CFuncPtr_Type.ob_type = &CFuncPtrType_Type;
|
||||
Py_Type(&CFuncPtr_Type) = &CFuncPtrType_Type;
|
||||
CFuncPtr_Type.tp_base = &CData_Type;
|
||||
if (PyType_Ready(&CFuncPtr_Type) < 0)
|
||||
return;
|
||||
|
|
|
@ -376,8 +376,7 @@ static PyMemberDef PyCArgType_members[] = {
|
|||
};
|
||||
|
||||
PyTypeObject PyCArg_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"CArgObject",
|
||||
sizeof(PyCArgObject),
|
||||
0,
|
||||
|
@ -1169,7 +1168,7 @@ call_commethod(PyObject *self, PyObject *args)
|
|||
if (!CDataObject_Check(pcom) || (pcom->b_size != sizeof(void *))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"COM Pointer expected instead of %s instance",
|
||||
pcom->ob_type->tp_name);
|
||||
Py_Type(pcom)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1409,7 +1408,7 @@ byref(PyObject *self, PyObject *obj)
|
|||
if (!CDataObject_Check(obj)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"byref() argument must be a ctypes instance, not '%s'",
|
||||
obj->ob_type->tp_name);
|
||||
Py_Type(obj)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,8 +274,7 @@ CField_repr(CFieldObject *self)
|
|||
}
|
||||
|
||||
PyTypeObject CField_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_ctypes.CField", /* tp_name */
|
||||
sizeof(CFieldObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -79,8 +79,7 @@ StgDict_clone(StgDictObject *dst, StgDictObject *src)
|
|||
}
|
||||
|
||||
PyTypeObject StgDict_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"StgDict",
|
||||
sizeof(StgDictObject),
|
||||
0,
|
||||
|
@ -184,7 +183,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
|
|||
Py_DECREF(fieldlist);
|
||||
return -1;
|
||||
}
|
||||
if (fdescr->ob_type != &CField_Type) {
|
||||
if (Py_Type(fdescr) != &CField_Type) {
|
||||
PyErr_SetString(PyExc_TypeError, "unexpected type");
|
||||
Py_DECREF(fdescr);
|
||||
Py_DECREF(fieldlist);
|
||||
|
@ -207,7 +206,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
|
|||
Py_DECREF(fieldlist);
|
||||
return -1;
|
||||
}
|
||||
assert(new_descr->ob_type == &CField_Type);
|
||||
assert(Py_Type(new_descr) == &CField_Type);
|
||||
new_descr->size = fdescr->size;
|
||||
new_descr->offset = fdescr->offset + offset;
|
||||
new_descr->index = fdescr->index + index;
|
||||
|
@ -255,7 +254,7 @@ MakeAnonFields(PyObject *type)
|
|||
Py_DECREF(anon_names);
|
||||
return -1;
|
||||
}
|
||||
assert(descr->ob_type == &CField_Type);
|
||||
assert(Py_Type(descr) == &CField_Type);
|
||||
descr->anonymous = 1;
|
||||
|
||||
/* descr is in the field descriptor. */
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct {
|
|||
|
||||
PyTypeObject PyCursesPanel_Type;
|
||||
|
||||
#define PyCursesPanel_Check(v) ((v)->ob_type == &PyCursesPanel_Type)
|
||||
#define PyCursesPanel_Check(v) (Py_Type(v) == &PyCursesPanel_Type)
|
||||
|
||||
/* Some helper functions. The problem is that there's always a window
|
||||
associated with a panel. To ensure that Python's GC doesn't pull
|
||||
|
@ -338,8 +338,7 @@ PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name)
|
|||
/* -------------------------------------------------------*/
|
||||
|
||||
PyTypeObject PyCursesPanel_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_curses_panel.curses panel", /*tp_name*/
|
||||
sizeof(PyCursesPanelObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -458,7 +457,7 @@ init_curses_panel(void)
|
|||
PyObject *m, *d, *v;
|
||||
|
||||
/* Initialize object type */
|
||||
PyCursesPanel_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&PyCursesPanel_Type) = &PyType_Type;
|
||||
|
||||
import_curses();
|
||||
|
||||
|
|
|
@ -1567,8 +1567,7 @@ PyCursesWindow_GetAttr(PyCursesWindowObject *self, char *name)
|
|||
/* -------------------------------------------------------*/
|
||||
|
||||
PyTypeObject PyCursesWindow_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_curses.curses window", /*tp_name*/
|
||||
sizeof(PyCursesWindowObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -2660,7 +2659,7 @@ init_curses(void)
|
|||
static void *PyCurses_API[PyCurses_API_pointers];
|
||||
|
||||
/* Initialize object type */
|
||||
PyCursesWindow_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&PyCursesWindow_Type) = &PyType_Type;
|
||||
|
||||
/* Initialize the C API pointer array */
|
||||
PyCurses_API[0] = (void *)&PyCursesWindow_Type;
|
||||
|
|
|
@ -248,7 +248,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Element_Type;
|
||||
|
||||
#define Element_CheckExact(op) ((op)->ob_type == &Element_Type)
|
||||
#define Element_CheckExact(op) (Py_Type(op) == &Element_Type)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* element constructor and destructor */
|
||||
|
@ -1174,7 +1174,7 @@ element_setslice(PyObject* self_, Py_ssize_t start, Py_ssize_t end, PyObject* it
|
|||
/* FIXME: support arbitrary sequences? */
|
||||
PyErr_Format(
|
||||
PyExc_TypeError,
|
||||
"expected list, not \"%.200s\"", item->ob_type->tp_name
|
||||
"expected list, not \"%.200s\"", Py_Type(item)->tp_name
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1367,8 +1367,8 @@ static PySequenceMethods element_as_sequence = {
|
|||
};
|
||||
|
||||
static PyTypeObject Element_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, "Element", sizeof(ElementObject), 0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"Element", sizeof(ElementObject), 0,
|
||||
/* methods */
|
||||
(destructor)element_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
|
@ -1407,7 +1407,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject TreeBuilder_Type;
|
||||
|
||||
#define TreeBuilder_CheckExact(op) ((op)->ob_type == &TreeBuilder_Type)
|
||||
#define TreeBuilder_CheckExact(op) (Py_Type(op) == &TreeBuilder_Type)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* constructor and destructor */
|
||||
|
@ -1574,7 +1574,7 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
|
|||
Py_INCREF(data); self->data = data;
|
||||
} else {
|
||||
/* more than one item; use a list to collect items */
|
||||
if (PyString_CheckExact(self->data) && self->data->ob_refcnt == 1 &&
|
||||
if (PyString_CheckExact(self->data) && Py_Refcnt(self->data) == 1 &&
|
||||
PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) {
|
||||
/* expat often generates single character data sections; handle
|
||||
the most common case by resizing the existing string... */
|
||||
|
@ -1780,8 +1780,8 @@ treebuilder_getattr(TreeBuilderObject* self, char* name)
|
|||
}
|
||||
|
||||
static PyTypeObject TreeBuilder_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, "TreeBuilder", sizeof(TreeBuilderObject), 0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"TreeBuilder", sizeof(TreeBuilderObject), 0,
|
||||
/* methods */
|
||||
(destructor)treebuilder_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
|
@ -2545,8 +2545,8 @@ xmlparser_getattr(XMLParserObject* self, char* name)
|
|||
}
|
||||
|
||||
static PyTypeObject XMLParser_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, "XMLParser", sizeof(XMLParserObject), 0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"XMLParser", sizeof(XMLParserObject), 0,
|
||||
/* methods */
|
||||
(destructor)xmlparser_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
|
@ -2580,9 +2580,9 @@ init_elementtree(void)
|
|||
#endif
|
||||
|
||||
/* Patch object type */
|
||||
Element_Type.ob_type = TreeBuilder_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&Element_Type) = Py_Type(&TreeBuilder_Type) = &PyType_Type;
|
||||
#if defined(USE_EXPAT)
|
||||
XMLParser_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&XMLParser_Type) = &PyType_Type;
|
||||
#endif
|
||||
|
||||
m = Py_InitModule("_elementtree", _functions);
|
||||
|
|
|
@ -281,7 +281,7 @@ fileio_dealloc(PyFileIOObject *self)
|
|||
Py_DECREF(closeresult);
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -820,8 +820,7 @@ static PyGetSetDef fileio_getsetlist[] = {
|
|||
};
|
||||
|
||||
PyTypeObject PyFileIO_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"FileIO",
|
||||
sizeof(PyFileIOObject),
|
||||
0,
|
||||
|
|
|
@ -81,7 +81,7 @@ partial_dealloc(partialobject *pto)
|
|||
Py_XDECREF(pto->args);
|
||||
Py_XDECREF(pto->kw);
|
||||
Py_XDECREF(pto->dict);
|
||||
pto->ob_type->tp_free(pto);
|
||||
Py_Type(pto)->tp_free(pto);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -197,8 +197,7 @@ static PyGetSetDef partial_getsetlist[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject partial_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"functools.partial", /* tp_name */
|
||||
sizeof(partialobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -276,8 +276,7 @@ name -- the hash algorithm being used by this object\n\
|
|||
digest_size -- number of bytes in this hashes output\n");
|
||||
|
||||
static PyTypeObject EVPtype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_hashlib.HASH", /*tp_name*/
|
||||
sizeof(EVPobject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -459,7 +458,7 @@ init_hashlib(void)
|
|||
* but having some be unsupported. Only init appropriate
|
||||
* constants. */
|
||||
|
||||
EVPtype.ob_type = &PyType_Type;
|
||||
Py_Type(&EVPtype) = &PyType_Type;
|
||||
if (PyType_Ready(&EVPtype) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1220,8 +1220,7 @@ PyDoc_STRVAR(profiler_object__doc__,
|
|||
"linetimings: True if line events collect timing information.");
|
||||
|
||||
static PyTypeObject ProfilerType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_hotshot.ProfilerType", /* tp_name */
|
||||
(int) sizeof(ProfilerObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1305,8 +1304,7 @@ static PyGetSetDef logreader_getsets[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject LogReaderType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_hotshot.LogReaderType", /* tp_name */
|
||||
(int) sizeof(LogReaderObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1613,8 +1611,8 @@ init_hotshot(void)
|
|||
{
|
||||
PyObject *module;
|
||||
|
||||
LogReaderType.ob_type = &PyType_Type;
|
||||
ProfilerType.ob_type = &PyType_Type;
|
||||
Py_Type(&LogReaderType) = &PyType_Type;
|
||||
Py_Type(&ProfilerType) = &PyType_Type;
|
||||
module = Py_InitModule("_hotshot", functions);
|
||||
if (module != NULL) {
|
||||
char *s = get_version_string();
|
||||
|
|
|
@ -120,7 +120,7 @@ typedef struct {
|
|||
static PyTypeObject PyProfiler_Type;
|
||||
|
||||
#define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type)
|
||||
#define PyProfiler_CheckExact(op) ((op)->ob_type == &PyProfiler_Type)
|
||||
#define PyProfiler_CheckExact(op) (Py_Type(op) == &PyProfiler_Type)
|
||||
|
||||
/*** External Timers ***/
|
||||
|
||||
|
@ -210,7 +210,7 @@ normalizeUserObj(PyObject *obj)
|
|||
PyObject *self = fn->m_self;
|
||||
PyObject *name = PyString_FromString(fn->m_ml->ml_name);
|
||||
if (name != NULL) {
|
||||
PyObject *mo = _PyType_Lookup(self->ob_type, name);
|
||||
PyObject *mo = _PyType_Lookup(Py_Type(self), name);
|
||||
Py_XINCREF(mo);
|
||||
Py_DECREF(name);
|
||||
if (mo != NULL) {
|
||||
|
@ -747,7 +747,7 @@ profiler_dealloc(ProfilerObject *op)
|
|||
flush_unmatched(op);
|
||||
clearEntries(op);
|
||||
Py_XDECREF(op->externalTimer);
|
||||
op->ob_type->tp_free(op);
|
||||
Py_Type(op)->tp_free(op);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -803,8 +803,7 @@ Profiler(custom_timer=None, time_unit=None, subcalls=True, builtins=True)\n\
|
|||
");
|
||||
|
||||
static PyTypeObject PyProfiler_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_lsprof.Profiler", /* tp_name */
|
||||
sizeof(ProfilerObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -84,7 +84,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Random_Type;
|
||||
|
||||
#define RandomObject_Check(v) ((v)->ob_type == &Random_Type)
|
||||
#define RandomObject_Check(v) (Py_Type(v) == &Random_Type)
|
||||
|
||||
|
||||
/* Random methods */
|
||||
|
@ -404,7 +404,7 @@ random_jumpahead(RandomObject *self, PyObject *n)
|
|||
if (!PyInt_Check(n) && !PyLong_Check(n)) {
|
||||
PyErr_Format(PyExc_TypeError, "jumpahead requires an "
|
||||
"integer, not '%s'",
|
||||
n->ob_type->tp_name);
|
||||
Py_Type(n)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -518,8 +518,7 @@ PyDoc_STRVAR(random_doc,
|
|||
"Random() -> create a random number generator with its own internal state.");
|
||||
|
||||
static PyTypeObject Random_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_random.Random", /*tp_name*/
|
||||
sizeof(RandomObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
|
@ -51,7 +51,7 @@ void pysqlite_node_dealloc(pysqlite_Node* self)
|
|||
Py_DECREF(self->key);
|
||||
Py_DECREF(self->data);
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs)
|
||||
|
@ -109,7 +109,7 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self)
|
|||
}
|
||||
Py_DECREF(self->mapping);
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args)
|
||||
|
@ -274,8 +274,7 @@ static PyMethodDef cache_methods[] = {
|
|||
};
|
||||
|
||||
PyTypeObject pysqlite_NodeType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME "Node", /* tp_name */
|
||||
sizeof(pysqlite_Node), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -317,8 +316,7 @@ PyTypeObject pysqlite_NodeType = {
|
|||
};
|
||||
|
||||
PyTypeObject pysqlite_CacheType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Cache", /* tp_name */
|
||||
sizeof(pysqlite_Cache), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -205,7 +205,7 @@ void pysqlite_connection_dealloc(pysqlite_Connection* self)
|
|||
Py_XDECREF(self->collations);
|
||||
Py_XDECREF(self->statements);
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
|
||||
|
@ -1206,8 +1206,7 @@ static struct PyMemberDef connection_members[] =
|
|||
};
|
||||
|
||||
PyTypeObject pysqlite_ConnectionType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Connection", /* tp_name */
|
||||
sizeof(pysqlite_Connection), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -134,7 +134,7 @@ void pysqlite_cursor_dealloc(pysqlite_Cursor* self)
|
|||
Py_XDECREF(self->row_factory);
|
||||
Py_XDECREF(self->next_row);
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyObject* _pysqlite_get_converter(PyObject* key)
|
||||
|
@ -1011,8 +1011,7 @@ static char cursor_doc[] =
|
|||
PyDoc_STR("SQLite database cursor class.");
|
||||
|
||||
PyTypeObject pysqlite_CursorType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Cursor", /* tp_name */
|
||||
sizeof(pysqlite_Cursor), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -30,12 +30,11 @@ int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* arg
|
|||
|
||||
void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self)
|
||||
{
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PyTypeObject pysqlite_PrepareProtocolType= {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".PrepareProtocol", /* tp_name */
|
||||
sizeof(pysqlite_PrepareProtocol), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -79,6 +78,6 @@ PyTypeObject pysqlite_PrepareProtocolType= {
|
|||
extern int pysqlite_prepare_protocol_setup_types(void)
|
||||
{
|
||||
pysqlite_PrepareProtocolType.tp_new = PyType_GenericNew;
|
||||
pysqlite_PrepareProtocolType.ob_type= &PyType_Type;
|
||||
Py_Type(&pysqlite_PrepareProtocolType)= &PyType_Type;
|
||||
return PyType_Ready(&pysqlite_PrepareProtocolType);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ void pysqlite_row_dealloc(pysqlite_Row* self)
|
|||
Py_XDECREF(self->data);
|
||||
Py_XDECREF(self->description);
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs)
|
||||
|
@ -183,8 +183,7 @@ static PyMethodDef pysqlite_row_methods[] = {
|
|||
|
||||
|
||||
PyTypeObject pysqlite_RowType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Row", /* tp_name */
|
||||
sizeof(pysqlite_Row), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -303,7 +303,7 @@ void pysqlite_statement_dealloc(pysqlite_Statement* self)
|
|||
PyObject_ClearWeakRefs((PyObject*)self);
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -377,8 +377,7 @@ static int pysqlite_check_remaining_sql(const char* tail)
|
|||
}
|
||||
|
||||
PyTypeObject pysqlite_StatementType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
MODULE_NAME ".Statement", /* tp_name */
|
||||
sizeof(pysqlite_Statement), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -1685,7 +1685,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
|
|||
#endif
|
||||
|
||||
/* get pointer to string buffer */
|
||||
buffer = string->ob_type->tp_as_buffer;
|
||||
buffer = Py_Type(string)->tp_as_buffer;
|
||||
if (!buffer || !buffer->bf_getreadbuffer || !buffer->bf_getsegcount ||
|
||||
buffer->bf_getsegcount(string, NULL) != 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "expected string or buffer");
|
||||
|
@ -2629,8 +2629,8 @@ pattern_getattr(PatternObject* self, char* name)
|
|||
}
|
||||
|
||||
static PyTypeObject Pattern_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, "_" SRE_MODULE ".SRE_Pattern",
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_" SRE_MODULE ".SRE_Pattern",
|
||||
sizeof(PatternObject), sizeof(SRE_CODE),
|
||||
(destructor)pattern_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
|
@ -3164,8 +3164,8 @@ match_getattr(MatchObject* self, char* name)
|
|||
detach the associated string, if any */
|
||||
|
||||
static PyTypeObject Match_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, "_" SRE_MODULE ".SRE_Match",
|
||||
PyVarObject_HEAD_INIT(NULL,0)
|
||||
"_" SRE_MODULE ".SRE_Match",
|
||||
sizeof(MatchObject), sizeof(Py_ssize_t),
|
||||
(destructor)match_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
|
@ -3339,8 +3339,8 @@ scanner_getattr(ScannerObject* self, char* name)
|
|||
}
|
||||
|
||||
static PyTypeObject Scanner_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, "_" SRE_MODULE ".SRE_Scanner",
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_" SRE_MODULE ".SRE_Scanner",
|
||||
sizeof(ScannerObject), 0,
|
||||
(destructor)scanner_dealloc, /*tp_dealloc*/
|
||||
0, /*tp_print*/
|
||||
|
|
|
@ -72,7 +72,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args);
|
|||
static int check_socket_and_wait_for_timeout(PySocketSockObject *s,
|
||||
int writing);
|
||||
|
||||
#define PySSLObject_Check(v) ((v)->ob_type == &PySSL_Type)
|
||||
#define PySSLObject_Check(v) (Py_Type(v) == &PySSL_Type)
|
||||
|
||||
typedef enum {
|
||||
SOCKET_IS_NONBLOCKING,
|
||||
|
@ -570,8 +570,7 @@ static PyObject *PySSL_getattr(PySSLObject *self, char *name)
|
|||
}
|
||||
|
||||
static PyTypeObject PySSL_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"socket.SSL", /*tp_name*/
|
||||
sizeof(PySSLObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -632,7 +631,7 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg)
|
|||
if (!PyString_Check(arg))
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"RAND_egd() expected string, found %s",
|
||||
arg->ob_type->tp_name);
|
||||
Py_Type(arg)->tp_name);
|
||||
bytes = RAND_egd(PyString_AS_STRING(arg));
|
||||
if (bytes == -1) {
|
||||
PyErr_SetString(PySSLErrorObject,
|
||||
|
@ -678,7 +677,7 @@ init_ssl(void)
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
PySSL_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&PySSL_Type) = &PyType_Type;
|
||||
|
||||
m = Py_InitModule3("_ssl", PySSL_methods, module_doc);
|
||||
if (m == NULL)
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
|
||||
|
||||
#define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType)
|
||||
#define PyStruct_CheckExact(op) ((op)->ob_type == &PyStructType)
|
||||
#define PyStruct_CheckExact(op) (Py_Type(op) == &PyStructType)
|
||||
|
||||
|
||||
/* Exception */
|
||||
|
@ -131,7 +131,7 @@ get_pylong(PyObject *v)
|
|||
Py_INCREF(v);
|
||||
return v;
|
||||
}
|
||||
m = v->ob_type->tp_as_number;
|
||||
m = Py_Type(v)->tp_as_number;
|
||||
if (m != NULL && m->nb_long != NULL) {
|
||||
v = m->nb_long(v);
|
||||
if (v == NULL)
|
||||
|
@ -1490,7 +1490,7 @@ s_dealloc(PyStructObject *s)
|
|||
PyMem_FREE(s->s_codes);
|
||||
}
|
||||
Py_XDECREF(s->s_format);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_Type(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1839,8 +1839,7 @@ static PyGetSetDef s_getsetlist[] = {
|
|||
|
||||
static
|
||||
PyTypeObject PyStructType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"Struct",
|
||||
sizeof(PyStructObject),
|
||||
0,
|
||||
|
@ -1890,7 +1889,7 @@ init_struct(void)
|
|||
if (m == NULL)
|
||||
return;
|
||||
|
||||
PyStructType.ob_type = &PyType_Type;
|
||||
Py_Type(&PyStructType) = &PyType_Type;
|
||||
if (PyType_Ready(&PyStructType) < 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -951,8 +951,7 @@ static void test_structmembers_free(PyObject *ob){
|
|||
}
|
||||
|
||||
static PyTypeObject test_structmembersType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"test_structmembersType",
|
||||
sizeof(test_structmembers), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1002,7 +1001,7 @@ init_testcapi(void)
|
|||
if (m == NULL)
|
||||
return;
|
||||
|
||||
test_structmembersType.ob_type=&PyType_Type;
|
||||
Py_Type(&test_structmembersType)=&PyType_Type;
|
||||
Py_INCREF(&test_structmembersType);
|
||||
PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType);
|
||||
|
||||
|
|
|
@ -262,12 +262,12 @@ typedef struct {
|
|||
Tcl_ObjType *StringType;
|
||||
} TkappObject;
|
||||
|
||||
#define Tkapp_Check(v) ((v)->ob_type == &Tkapp_Type)
|
||||
#define Tkapp_Check(v) (Py_Type(v) == &Tkapp_Type)
|
||||
#define Tkapp_Interp(v) (((TkappObject *) (v))->interp)
|
||||
#define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v))
|
||||
|
||||
#define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \
|
||||
(void *) v, ((PyObject *) v)->ob_refcnt))
|
||||
(void *) v, Py_Refcnt(v)))
|
||||
|
||||
|
||||
|
||||
|
@ -828,8 +828,7 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject PyTclObject_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_tkinter.Tcl_Obj", /*tp_name*/
|
||||
sizeof(PyTclObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -2371,8 +2370,7 @@ Tktt_GetAttr(PyObject *self, char *name)
|
|||
|
||||
static PyTypeObject Tktt_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"tktimertoken", /*tp_name */
|
||||
sizeof(TkttObject), /*tp_basicsize */
|
||||
0, /*tp_itemsize */
|
||||
|
@ -2716,8 +2714,7 @@ Tkapp_GetAttr(PyObject *self, char *name)
|
|||
|
||||
static PyTypeObject Tkapp_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"tkapp", /*tp_name */
|
||||
sizeof(TkappObject), /*tp_basicsize */
|
||||
0, /*tp_itemsize */
|
||||
|
@ -3056,7 +3053,7 @@ init_tkinter(void)
|
|||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
Tkapp_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&Tkapp_Type) = &PyType_Type;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
tcl_lock = PyThread_allocate_lock();
|
||||
|
@ -3084,10 +3081,10 @@ init_tkinter(void)
|
|||
|
||||
PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type);
|
||||
|
||||
Tktt_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&Tktt_Type) = &PyType_Type;
|
||||
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
|
||||
|
||||
PyTclObject_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&PyTclObject_Type) = &PyType_Type;
|
||||
PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type);
|
||||
|
||||
#ifdef TK_AQUA
|
||||
|
|
|
@ -33,8 +33,7 @@ static PyGetSetDef helper_getset[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject HelperType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_types.Helper", /* tp_name */
|
||||
sizeof(Helper), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -14,7 +14,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *object)
|
|||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
|
||||
if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) {
|
||||
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
|
||||
|
||||
result = PyInt_FromSsize_t(_PyWeakref_GetWeakrefCount(*list));
|
||||
|
@ -35,7 +35,7 @@ weakref_getweakrefs(PyObject *self, PyObject *object)
|
|||
{
|
||||
PyObject *result = NULL;
|
||||
|
||||
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
|
||||
if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) {
|
||||
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
|
||||
Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct arrayobject {
|
|||
static PyTypeObject Arraytype;
|
||||
|
||||
#define array_Check(op) PyObject_TypeCheck(op, &Arraytype)
|
||||
#define array_CheckExact(op) ((op)->ob_type == &Arraytype)
|
||||
#define array_CheckExact(op) (Py_Type(op) == &Arraytype)
|
||||
|
||||
static int
|
||||
array_resize(arrayobject *self, Py_ssize_t newsize)
|
||||
|
@ -53,9 +53,9 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
|||
*/
|
||||
|
||||
if (self->allocated >= newsize &&
|
||||
self->ob_size < newsize + 16 &&
|
||||
Py_Size(self) < newsize + 16 &&
|
||||
self->ob_item != NULL) {
|
||||
self->ob_size = newsize;
|
||||
Py_Size(self) = newsize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
|||
* memory critical.
|
||||
*/
|
||||
|
||||
_new_size = (newsize >> 4) + (self->ob_size < 8 ? 3 : 7) + newsize;
|
||||
_new_size = (newsize >> 4) + (Py_Size(self) < 8 ? 3 : 7) + newsize;
|
||||
items = self->ob_item;
|
||||
/* XXX The following multiplication and division does not optimize away
|
||||
like it does for lists since the size is not known at compile time */
|
||||
|
@ -84,7 +84,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
|||
return -1;
|
||||
}
|
||||
self->ob_item = items;
|
||||
self->ob_size = newsize;
|
||||
Py_Size(self) = newsize;
|
||||
self->allocated = _new_size;
|
||||
return 0;
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr)
|
|||
if (op == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
op->ob_size = size;
|
||||
Py_Size(op) = size;
|
||||
if (size <= 0) {
|
||||
op->ob_item = NULL;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ getarrayitem(PyObject *op, Py_ssize_t i)
|
|||
register arrayobject *ap;
|
||||
assert(array_Check(op));
|
||||
ap = (arrayobject *)op;
|
||||
assert(i>=0 && i<ap->ob_size);
|
||||
assert(i>=0 && i<Py_Size(ap));
|
||||
return (*ap->ob_descr->getitem)(ap, i);
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ static int
|
|||
ins1(arrayobject *self, Py_ssize_t where, PyObject *v)
|
||||
{
|
||||
char *items;
|
||||
Py_ssize_t n = self->ob_size;
|
||||
Py_ssize_t n = Py_Size(self);
|
||||
if (v == NULL) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
|
@ -476,7 +476,7 @@ array_dealloc(arrayobject *op)
|
|||
PyObject_ClearWeakRefs((PyObject *) op);
|
||||
if (op->ob_item != NULL)
|
||||
PyMem_DEL(op->ob_item);
|
||||
op->ob_type->tp_free((PyObject *)op);
|
||||
Py_Type(op)->tp_free((PyObject *)op);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -496,7 +496,7 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
va = (arrayobject *)v;
|
||||
wa = (arrayobject *)w;
|
||||
|
||||
if (va->ob_size != wa->ob_size && (op == Py_EQ || op == Py_NE)) {
|
||||
if (Py_Size(va) != Py_Size(wa) && (op == Py_EQ || op == Py_NE)) {
|
||||
/* Shortcut: if the lengths differ, the arrays differ */
|
||||
if (op == Py_EQ)
|
||||
res = Py_False;
|
||||
|
@ -508,7 +508,7 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
|
||||
/* Search for the first index where items are different */
|
||||
k = 1;
|
||||
for (i = 0; i < va->ob_size && i < wa->ob_size; i++) {
|
||||
for (i = 0; i < Py_Size(va) && i < Py_Size(wa); i++) {
|
||||
vi = getarrayitem(v, i);
|
||||
wi = getarrayitem(w, i);
|
||||
if (vi == NULL || wi == NULL) {
|
||||
|
@ -527,8 +527,8 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
|
||||
if (k) {
|
||||
/* No more items to compare -- compare sizes */
|
||||
Py_ssize_t vs = va->ob_size;
|
||||
Py_ssize_t ws = wa->ob_size;
|
||||
Py_ssize_t vs = Py_Size(va);
|
||||
Py_ssize_t ws = Py_Size(wa);
|
||||
int cmp;
|
||||
switch (op) {
|
||||
case Py_LT: cmp = vs < ws; break;
|
||||
|
@ -568,13 +568,13 @@ array_richcompare(PyObject *v, PyObject *w, int op)
|
|||
static Py_ssize_t
|
||||
array_length(arrayobject *a)
|
||||
{
|
||||
return a->ob_size;
|
||||
return Py_Size(a);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
array_item(arrayobject *a, Py_ssize_t i)
|
||||
{
|
||||
if (i < 0 || i >= a->ob_size) {
|
||||
if (i < 0 || i >= Py_Size(a)) {
|
||||
PyErr_SetString(PyExc_IndexError, "array index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -587,14 +587,14 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
|
|||
arrayobject *np;
|
||||
if (ilow < 0)
|
||||
ilow = 0;
|
||||
else if (ilow > a->ob_size)
|
||||
ilow = a->ob_size;
|
||||
else if (ilow > Py_Size(a))
|
||||
ilow = Py_Size(a);
|
||||
if (ihigh < 0)
|
||||
ihigh = 0;
|
||||
if (ihigh < ilow)
|
||||
ihigh = ilow;
|
||||
else if (ihigh > a->ob_size)
|
||||
ihigh = a->ob_size;
|
||||
else if (ihigh > Py_Size(a))
|
||||
ihigh = Py_Size(a);
|
||||
np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr);
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
|
@ -606,7 +606,7 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
|
|||
static PyObject *
|
||||
array_copy(arrayobject *a, PyObject *unused)
|
||||
{
|
||||
return array_slice(a, 0, a->ob_size);
|
||||
return array_slice(a, 0, Py_Size(a));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(copy_doc,
|
||||
|
@ -622,7 +622,7 @@ array_concat(arrayobject *a, PyObject *bb)
|
|||
if (!array_Check(bb)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only append array (not \"%.200s\") to array",
|
||||
bb->ob_type->tp_name);
|
||||
Py_Type(bb)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
#define b ((arrayobject *)bb)
|
||||
|
@ -630,14 +630,14 @@ array_concat(arrayobject *a, PyObject *bb)
|
|||
PyErr_BadArgument();
|
||||
return NULL;
|
||||
}
|
||||
size = a->ob_size + b->ob_size;
|
||||
size = Py_Size(a) + Py_Size(b);
|
||||
np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
|
||||
if (np == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memcpy(np->ob_item, a->ob_item, a->ob_size*a->ob_descr->itemsize);
|
||||
memcpy(np->ob_item + a->ob_size*a->ob_descr->itemsize,
|
||||
b->ob_item, b->ob_size*b->ob_descr->itemsize);
|
||||
memcpy(np->ob_item, a->ob_item, Py_Size(a)*a->ob_descr->itemsize);
|
||||
memcpy(np->ob_item + Py_Size(a)*a->ob_descr->itemsize,
|
||||
b->ob_item, Py_Size(b)*b->ob_descr->itemsize);
|
||||
return (PyObject *)np;
|
||||
#undef b
|
||||
}
|
||||
|
@ -652,12 +652,12 @@ array_repeat(arrayobject *a, Py_ssize_t n)
|
|||
Py_ssize_t nbytes;
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
size = a->ob_size * n;
|
||||
size = Py_Size(a) * n;
|
||||
np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
|
||||
if (np == NULL)
|
||||
return NULL;
|
||||
p = np->ob_item;
|
||||
nbytes = a->ob_size * a->ob_descr->itemsize;
|
||||
nbytes = Py_Size(a) * a->ob_descr->itemsize;
|
||||
for (i = 0; i < n; i++) {
|
||||
memcpy(p, a->ob_item, nbytes);
|
||||
p += nbytes;
|
||||
|
@ -675,7 +675,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
if (v == NULL)
|
||||
n = 0;
|
||||
else if (array_Check(v)) {
|
||||
n = b->ob_size;
|
||||
n = Py_Size(b);
|
||||
if (a == b) {
|
||||
/* Special case "a[i:j] = a" -- copy b first */
|
||||
int ret;
|
||||
|
@ -694,44 +694,44 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only assign array (not \"%.200s\") to array slice",
|
||||
v->ob_type->tp_name);
|
||||
Py_Type(v)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (ilow < 0)
|
||||
ilow = 0;
|
||||
else if (ilow > a->ob_size)
|
||||
ilow = a->ob_size;
|
||||
else if (ilow > Py_Size(a))
|
||||
ilow = Py_Size(a);
|
||||
if (ihigh < 0)
|
||||
ihigh = 0;
|
||||
if (ihigh < ilow)
|
||||
ihigh = ilow;
|
||||
else if (ihigh > a->ob_size)
|
||||
ihigh = a->ob_size;
|
||||
else if (ihigh > Py_Size(a))
|
||||
ihigh = Py_Size(a);
|
||||
item = a->ob_item;
|
||||
d = n - (ihigh-ilow);
|
||||
if (d < 0) { /* Delete -d items */
|
||||
memmove(item + (ihigh+d)*a->ob_descr->itemsize,
|
||||
item + ihigh*a->ob_descr->itemsize,
|
||||
(a->ob_size-ihigh)*a->ob_descr->itemsize);
|
||||
a->ob_size += d;
|
||||
PyMem_RESIZE(item, char, a->ob_size*a->ob_descr->itemsize);
|
||||
(Py_Size(a)-ihigh)*a->ob_descr->itemsize);
|
||||
Py_Size(a) += d;
|
||||
PyMem_RESIZE(item, char, Py_Size(a)*a->ob_descr->itemsize);
|
||||
/* Can't fail */
|
||||
a->ob_item = item;
|
||||
a->allocated = a->ob_size;
|
||||
a->allocated = Py_Size(a);
|
||||
}
|
||||
else if (d > 0) { /* Insert d items */
|
||||
PyMem_RESIZE(item, char,
|
||||
(a->ob_size + d)*a->ob_descr->itemsize);
|
||||
(Py_Size(a) + d)*a->ob_descr->itemsize);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return -1;
|
||||
}
|
||||
memmove(item + (ihigh+d)*a->ob_descr->itemsize,
|
||||
item + ihigh*a->ob_descr->itemsize,
|
||||
(a->ob_size-ihigh)*a->ob_descr->itemsize);
|
||||
(Py_Size(a)-ihigh)*a->ob_descr->itemsize);
|
||||
a->ob_item = item;
|
||||
a->ob_size += d;
|
||||
a->allocated = a->ob_size;
|
||||
Py_Size(a) += d;
|
||||
a->allocated = Py_Size(a);
|
||||
}
|
||||
if (n > 0)
|
||||
memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item,
|
||||
|
@ -743,7 +743,7 @@ array_ass_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
|||
static int
|
||||
array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v)
|
||||
{
|
||||
if (i < 0 || i >= a->ob_size) {
|
||||
if (i < 0 || i >= Py_Size(a)) {
|
||||
PyErr_SetString(PyExc_IndexError,
|
||||
"array assignment index out of range");
|
||||
return -1;
|
||||
|
@ -770,7 +770,7 @@ array_iter_extend(arrayobject *self, PyObject *bb)
|
|||
return -1;
|
||||
|
||||
while ((v = PyIter_Next(it)) != NULL) {
|
||||
if (ins1(self, (int) self->ob_size, v) != 0) {
|
||||
if (ins1(self, (int) Py_Size(self), v) != 0) {
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(it);
|
||||
return -1;
|
||||
|
@ -796,16 +796,16 @@ array_do_extend(arrayobject *self, PyObject *bb)
|
|||
"can only extend with array of same kind");
|
||||
return -1;
|
||||
}
|
||||
size = self->ob_size + b->ob_size;
|
||||
size = Py_Size(self) + Py_Size(b);
|
||||
PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize);
|
||||
if (self->ob_item == NULL) {
|
||||
PyObject_Del(self);
|
||||
PyErr_NoMemory();
|
||||
return -1;
|
||||
}
|
||||
memcpy(self->ob_item + self->ob_size*self->ob_descr->itemsize,
|
||||
b->ob_item, b->ob_size*b->ob_descr->itemsize);
|
||||
self->ob_size = size;
|
||||
memcpy(self->ob_item + Py_Size(self)*self->ob_descr->itemsize,
|
||||
b->ob_item, Py_Size(b)*b->ob_descr->itemsize);
|
||||
Py_Size(self) = size;
|
||||
self->allocated = size;
|
||||
|
||||
return 0;
|
||||
|
@ -818,7 +818,7 @@ array_inplace_concat(arrayobject *self, PyObject *bb)
|
|||
if (!array_Check(bb)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can only extend array with array (not \"%.200s\")",
|
||||
bb->ob_type->tp_name);
|
||||
Py_Type(bb)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
if (array_do_extend(self, bb) == -1)
|
||||
|
@ -833,15 +833,15 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n)
|
|||
char *items, *p;
|
||||
Py_ssize_t size, i;
|
||||
|
||||
if (self->ob_size > 0) {
|
||||
if (Py_Size(self) > 0) {
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
items = self->ob_item;
|
||||
size = self->ob_size * self->ob_descr->itemsize;
|
||||
size = Py_Size(self) * self->ob_descr->itemsize;
|
||||
if (n == 0) {
|
||||
PyMem_FREE(items);
|
||||
self->ob_item = NULL;
|
||||
self->ob_size = 0;
|
||||
Py_Size(self) = 0;
|
||||
self->allocated = 0;
|
||||
}
|
||||
else {
|
||||
|
@ -854,8 +854,8 @@ array_inplace_repeat(arrayobject *self, Py_ssize_t n)
|
|||
memcpy(p, items, size);
|
||||
}
|
||||
self->ob_item = items;
|
||||
self->ob_size *= n;
|
||||
self->allocated = self->ob_size;
|
||||
Py_Size(self) *= n;
|
||||
self->allocated = Py_Size(self);
|
||||
}
|
||||
}
|
||||
Py_INCREF(self);
|
||||
|
@ -878,7 +878,7 @@ array_count(arrayobject *self, PyObject *v)
|
|||
Py_ssize_t count = 0;
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = 0; i < self->ob_size; i++) {
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self, i);
|
||||
int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -900,7 +900,7 @@ array_index(arrayobject *self, PyObject *v)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
for (i = 0; i < self->ob_size; i++) {
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self, i);
|
||||
int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -925,7 +925,7 @@ array_contains(arrayobject *self, PyObject *v)
|
|||
Py_ssize_t i;
|
||||
int cmp;
|
||||
|
||||
for (i = 0, cmp = 0 ; cmp == 0 && i < self->ob_size; i++) {
|
||||
for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self, i);
|
||||
cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -938,7 +938,7 @@ array_remove(arrayobject *self, PyObject *v)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < self->ob_size; i++) {
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
PyObject *selfi = getarrayitem((PyObject *)self,i);
|
||||
int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ);
|
||||
Py_DECREF(selfi);
|
||||
|
@ -968,14 +968,14 @@ array_pop(arrayobject *self, PyObject *args)
|
|||
PyObject *v;
|
||||
if (!PyArg_ParseTuple(args, "|n:pop", &i))
|
||||
return NULL;
|
||||
if (self->ob_size == 0) {
|
||||
if (Py_Size(self) == 0) {
|
||||
/* Special-case most common failure cause */
|
||||
PyErr_SetString(PyExc_IndexError, "pop from empty array");
|
||||
return NULL;
|
||||
}
|
||||
if (i < 0)
|
||||
i += self->ob_size;
|
||||
if (i < 0 || i >= self->ob_size) {
|
||||
i += Py_Size(self);
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "pop index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1031,7 +1031,7 @@ array_buffer_info(arrayobject *self, PyObject *unused)
|
|||
return NULL;
|
||||
|
||||
PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item));
|
||||
PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(self->ob_size)));
|
||||
PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_Size(self))));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1048,7 +1048,7 @@ the buffer length in bytes.");
|
|||
static PyObject *
|
||||
array_append(arrayobject *self, PyObject *v)
|
||||
{
|
||||
return ins(self, (int) self->ob_size, v);
|
||||
return ins(self, (int) Py_Size(self), v);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(append_doc,
|
||||
|
@ -1067,14 +1067,14 @@ array_byteswap(arrayobject *self, PyObject *unused)
|
|||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 2) {
|
||||
for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 2) {
|
||||
char p0 = p[0];
|
||||
p[0] = p[1];
|
||||
p[1] = p0;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 4) {
|
||||
for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 4) {
|
||||
char p0 = p[0];
|
||||
char p1 = p[1];
|
||||
p[0] = p[3];
|
||||
|
@ -1084,7 +1084,7 @@ array_byteswap(arrayobject *self, PyObject *unused)
|
|||
}
|
||||
break;
|
||||
case 8:
|
||||
for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 8) {
|
||||
for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 8) {
|
||||
char p0 = p[0];
|
||||
char p1 = p[1];
|
||||
char p2 = p[2];
|
||||
|
@ -1125,16 +1125,16 @@ array_reduce(arrayobject *array)
|
|||
dict = Py_None;
|
||||
Py_INCREF(dict);
|
||||
}
|
||||
if (array->ob_size > 0) {
|
||||
if (Py_Size(array) > 0) {
|
||||
result = Py_BuildValue("O(cy#)O",
|
||||
array->ob_type,
|
||||
Py_Type(array),
|
||||
array->ob_descr->typecode,
|
||||
array->ob_item,
|
||||
array->ob_size * array->ob_descr->itemsize,
|
||||
Py_Size(array) * array->ob_descr->itemsize,
|
||||
dict);
|
||||
} else {
|
||||
result = Py_BuildValue("O(c)O",
|
||||
array->ob_type,
|
||||
Py_Type(array),
|
||||
array->ob_descr->typecode,
|
||||
dict);
|
||||
}
|
||||
|
@ -1153,9 +1153,9 @@ array_reverse(arrayobject *self, PyObject *unused)
|
|||
char tmp[256]; /* 8 is probably enough -- but why skimp */
|
||||
assert((size_t)itemsize <= sizeof(tmp));
|
||||
|
||||
if (self->ob_size > 1) {
|
||||
if (Py_Size(self) > 1) {
|
||||
for (p = self->ob_item,
|
||||
q = self->ob_item + (self->ob_size - 1)*itemsize;
|
||||
q = self->ob_item + (Py_Size(self) - 1)*itemsize;
|
||||
p < q;
|
||||
p += itemsize, q -= itemsize) {
|
||||
/* memory areas guaranteed disjoint, so memcpy
|
||||
|
@ -1242,7 +1242,7 @@ array_tofile(arrayobject *self, PyObject *f)
|
|||
Py_ssize_t nblocks = (nbytes + BLOCKSIZE - 1) / BLOCKSIZE;
|
||||
Py_ssize_t i;
|
||||
|
||||
if (self->ob_size == 0)
|
||||
if (Py_Size(self) == 0)
|
||||
goto done;
|
||||
|
||||
for (i = 0; i < nblocks; i++) {
|
||||
|
@ -1286,23 +1286,23 @@ array_fromlist(arrayobject *self, PyObject *list)
|
|||
if (n > 0) {
|
||||
char *item = self->ob_item;
|
||||
Py_ssize_t i;
|
||||
PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize);
|
||||
PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
self->ob_size += n;
|
||||
self->allocated = self->ob_size;
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
for (i = 0; i < n; i++) {
|
||||
PyObject *v = PyList_GetItem(list, i);
|
||||
if ((*self->ob_descr->setitem)(self,
|
||||
self->ob_size - n + i, v) != 0) {
|
||||
self->ob_size -= n;
|
||||
Py_Size(self) - n + i, v) != 0) {
|
||||
Py_Size(self) -= n;
|
||||
PyMem_RESIZE(item, char,
|
||||
self->ob_size * itemsize);
|
||||
Py_Size(self) * itemsize);
|
||||
self->ob_item = item;
|
||||
self->allocated = self->ob_size;
|
||||
self->allocated = Py_Size(self);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1319,12 +1319,12 @@ Append items to array from list.");
|
|||
static PyObject *
|
||||
array_tolist(arrayobject *self, PyObject *unused)
|
||||
{
|
||||
PyObject *list = PyList_New(self->ob_size);
|
||||
PyObject *list = PyList_New(Py_Size(self));
|
||||
Py_ssize_t i;
|
||||
|
||||
if (list == NULL)
|
||||
return NULL;
|
||||
for (i = 0; i < self->ob_size; i++) {
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
PyObject *v = getarrayitem((PyObject *)self, i);
|
||||
if (v == NULL) {
|
||||
Py_DECREF(list);
|
||||
|
@ -1357,15 +1357,15 @@ array_fromstring(arrayobject *self, PyObject *args)
|
|||
n = n / itemsize;
|
||||
if (n > 0) {
|
||||
char *item = self->ob_item;
|
||||
PyMem_RESIZE(item, char, (self->ob_size + n) * itemsize);
|
||||
PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
self->ob_size += n;
|
||||
self->allocated = self->ob_size;
|
||||
memcpy(item + (self->ob_size - n) * itemsize,
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
memcpy(item + (Py_Size(self) - n) * itemsize,
|
||||
str, itemsize*n);
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -1410,15 +1410,15 @@ array_fromunicode(arrayobject *self, PyObject *args)
|
|||
}
|
||||
if (n > 0) {
|
||||
Py_UNICODE *item = (Py_UNICODE *) self->ob_item;
|
||||
PyMem_RESIZE(item, Py_UNICODE, self->ob_size + n);
|
||||
PyMem_RESIZE(item, Py_UNICODE, Py_Size(self) + n);
|
||||
if (item == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
self->ob_item = (char *) item;
|
||||
self->ob_size += n;
|
||||
self->allocated = self->ob_size;
|
||||
memcpy(item + self->ob_size - n,
|
||||
Py_Size(self) += n;
|
||||
self->allocated = Py_Size(self);
|
||||
memcpy(item + Py_Size(self) - n,
|
||||
ustr, n * sizeof(Py_UNICODE));
|
||||
}
|
||||
|
||||
|
@ -1443,7 +1443,7 @@ array_tounicode(arrayobject *self, PyObject *unused)
|
|||
"tounicode() may only be called on type 'u' arrays");
|
||||
return NULL;
|
||||
}
|
||||
return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, self->ob_size);
|
||||
return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_Size(self));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(tounicode_doc,
|
||||
|
@ -1536,7 +1536,7 @@ array_repr(arrayobject *a)
|
|||
PyObject *s, *v = NULL;
|
||||
Py_ssize_t len;
|
||||
|
||||
len = a->ob_size;
|
||||
len = Py_Size(a);
|
||||
typecode = a->ob_descr->typecode;
|
||||
if (len == 0) {
|
||||
return PyUnicode_FromFormat("array('%c')", typecode);
|
||||
|
@ -1560,7 +1560,7 @@ array_subscr(arrayobject* self, PyObject* item)
|
|||
return NULL;
|
||||
}
|
||||
if (i < 0)
|
||||
i += self->ob_size;
|
||||
i += Py_Size(self);
|
||||
return array_item(self, i);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
|
@ -1569,7 +1569,7 @@ array_subscr(arrayobject* self, PyObject* item)
|
|||
arrayobject* ar;
|
||||
int itemsize = self->ob_descr->itemsize;
|
||||
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size,
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
|
||||
&start, &stop, &step, &slicelength) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1608,14 +1608,14 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
if (i==-1 && PyErr_Occurred())
|
||||
return -1;
|
||||
if (i < 0)
|
||||
i += self->ob_size;
|
||||
i += Py_Size(self);
|
||||
return array_ass_item(self, i, value);
|
||||
}
|
||||
else if (PySlice_Check(item)) {
|
||||
Py_ssize_t start, stop, step, slicelength;
|
||||
int itemsize = self->ob_descr->itemsize;
|
||||
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size,
|
||||
if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self),
|
||||
&start, &stop, &step, &slicelength) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1643,17 +1643,17 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
self->ob_item + (cur + 1)*itemsize,
|
||||
(step - 1) * itemsize);
|
||||
}
|
||||
extra = self->ob_size - (cur + 1);
|
||||
extra = Py_Size(self) - (cur + 1);
|
||||
if (extra > 0) {
|
||||
memmove(self->ob_item + (cur - i)*itemsize,
|
||||
self->ob_item + (cur + 1)*itemsize,
|
||||
extra*itemsize);
|
||||
}
|
||||
|
||||
self->ob_size -= slicelength;
|
||||
Py_Size(self) -= slicelength;
|
||||
self->ob_item = (char *)PyMem_REALLOC(self->ob_item,
|
||||
itemsize*self->ob_size);
|
||||
self->allocated = self->ob_size;
|
||||
itemsize*Py_Size(self));
|
||||
self->allocated = Py_Size(self);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1665,16 +1665,16 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
if (!array_Check(value)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"must assign array (not \"%.200s\") to slice",
|
||||
value->ob_type->tp_name);
|
||||
Py_Type(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
av = (arrayobject*)value;
|
||||
|
||||
if (av->ob_size != slicelength) {
|
||||
if (Py_Size(av) != slicelength) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"attempt to assign array of size %ld to extended slice of size %ld",
|
||||
/*XXX*/(long)av->ob_size, /*XXX*/(long)slicelength);
|
||||
/*XXX*/(long)Py_Size(av), /*XXX*/(long)slicelength);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1683,7 +1683,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
|
|||
|
||||
/* protect against a[::-1] = a */
|
||||
if (self == av) {
|
||||
value = array_slice(av, 0, av->ob_size);
|
||||
value = array_slice(av, 0, Py_Size(av));
|
||||
av = (arrayobject*)value;
|
||||
if (!av)
|
||||
return -1;
|
||||
|
@ -1730,7 +1730,7 @@ array_buffer_getreadbuf(arrayobject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = (void *)self->ob_item;
|
||||
if (*ptr == NULL)
|
||||
*ptr = emptybuf;
|
||||
return self->ob_size*self->ob_descr->itemsize;
|
||||
return Py_Size(self)*self->ob_descr->itemsize;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
|
@ -1744,14 +1744,14 @@ array_buffer_getwritebuf(arrayobject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = (void *)self->ob_item;
|
||||
if (*ptr == NULL)
|
||||
*ptr = emptybuf;
|
||||
return self->ob_size*self->ob_descr->itemsize;
|
||||
return Py_Size(self)*self->ob_descr->itemsize;
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
array_buffer_getsegcount(arrayobject *self, Py_ssize_t *lenp)
|
||||
{
|
||||
if ( lenp )
|
||||
*lenp = self->ob_size*self->ob_descr->itemsize;
|
||||
*lenp = Py_Size(self)*self->ob_descr->itemsize;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1861,9 +1861,9 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
self->ob_item = item;
|
||||
self->ob_size = n / sizeof(Py_UNICODE);
|
||||
Py_Size(self) = n / sizeof(Py_UNICODE);
|
||||
memcpy(item, PyUnicode_AS_DATA(initial), n);
|
||||
self->allocated = self->ob_size;
|
||||
self->allocated = Py_Size(self);
|
||||
}
|
||||
}
|
||||
if (it != NULL) {
|
||||
|
@ -1949,8 +1949,7 @@ itemsize -- the length in bytes of one array item\n\
|
|||
static PyObject *array_iter(arrayobject *ao);
|
||||
|
||||
static PyTypeObject Arraytype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"array.array",
|
||||
sizeof(arrayobject),
|
||||
0,
|
||||
|
@ -2031,7 +2030,7 @@ static PyObject *
|
|||
arrayiter_next(arrayiterobject *it)
|
||||
{
|
||||
assert(PyArrayIter_Check(it));
|
||||
if (it->index < it->ao->ob_size)
|
||||
if (it->index < Py_Size(it->ao))
|
||||
return (*it->getitem)(it->ao, it->index++);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2052,8 +2051,7 @@ arrayiter_traverse(arrayiterobject *it, visitproc visit, void *arg)
|
|||
}
|
||||
|
||||
static PyTypeObject PyArrayIter_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"arrayiterator", /* tp_name */
|
||||
sizeof(arrayiterobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2100,7 +2098,7 @@ initarray(void)
|
|||
|
||||
if (PyType_Ready(&Arraytype) < 0)
|
||||
return;
|
||||
PyArrayIter_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&PyArrayIter_Type) = &PyType_Type;
|
||||
m = Py_InitModule3("array", a_methods, module_doc);
|
||||
if (m == NULL)
|
||||
return;
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef fpos_t Py_off_t;
|
|||
#define MODE_READ_EOF 2
|
||||
#define MODE_WRITE 3
|
||||
|
||||
#define BZ2FileObject_Check(v) ((v)->ob_type == &BZ2File_Type)
|
||||
#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type)
|
||||
|
||||
|
||||
#ifdef BZ_CONFIG_ERROR
|
||||
|
@ -1245,7 +1245,7 @@ BZ2File_dealloc(BZ2FileObject *self)
|
|||
Util_DropReadAhead(self);
|
||||
if (self->rawfp != NULL)
|
||||
fclose(self->rawfp);
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
/* This is a hacked version of Python's fileobject.c:file_getiter(). */
|
||||
|
@ -1298,8 +1298,7 @@ Data read is always returned in bytes; data written ought to be bytes.\n\
|
|||
");
|
||||
|
||||
static PyTypeObject BZ2File_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"bz2.BZ2File", /*tp_name*/
|
||||
sizeof(BZ2FileObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -1558,7 +1557,7 @@ BZ2Comp_dealloc(BZ2CompObject *self)
|
|||
PyThread_free_lock(self->lock);
|
||||
#endif
|
||||
BZ2_bzCompressEnd(&self->bzs);
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1575,8 +1574,7 @@ must be a number between 1 and 9.\n\
|
|||
");
|
||||
|
||||
static PyTypeObject BZ2Comp_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"bz2.BZ2Compressor", /*tp_name*/
|
||||
sizeof(BZ2CompObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -1784,7 +1782,7 @@ BZ2Decomp_dealloc(BZ2DecompObject *self)
|
|||
#endif
|
||||
Py_XDECREF(self->unused_data);
|
||||
BZ2_bzDecompressEnd(&self->bzs);
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1800,8 +1798,7 @@ decompress() function instead.\n\
|
|||
");
|
||||
|
||||
static PyTypeObject BZ2Decomp_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"bz2.BZ2Decompressor", /*tp_name*/
|
||||
sizeof(BZ2DecompObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -2043,9 +2040,9 @@ initbz2(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
BZ2File_Type.ob_type = &PyType_Type;
|
||||
BZ2Comp_Type.ob_type = &PyType_Type;
|
||||
BZ2Decomp_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&BZ2File_Type) = &PyType_Type;
|
||||
Py_Type(&BZ2Comp_Type) = &PyType_Type;
|
||||
Py_Type(&BZ2Decomp_Type) = &PyType_Type;
|
||||
|
||||
m = Py_InitModule3("bz2", bz2_methods, bz2__doc__);
|
||||
if (m == NULL)
|
||||
|
|
|
@ -506,8 +506,7 @@ O_dealloc(Oobject *self) {
|
|||
PyDoc_STRVAR(Otype__doc__, "Simple type for output to strings.");
|
||||
|
||||
static PyTypeObject Otype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"cStringIO.StringO", /*tp_name*/
|
||||
sizeof(Oobject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -626,8 +625,7 @@ PyDoc_STRVAR(Itype__doc__,
|
|||
"Simple type for treating strings as input file streams");
|
||||
|
||||
static PyTypeObject Itype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"cStringIO.StringI", /*tp_name*/
|
||||
sizeof(Iobject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -737,8 +735,8 @@ initcStringIO(void) {
|
|||
d = PyModule_GetDict(m);
|
||||
|
||||
/* Export C API */
|
||||
Itype.ob_type=&PyType_Type;
|
||||
Otype.ob_type=&PyType_Type;
|
||||
Py_Type(&Itype)=&PyType_Type;
|
||||
Py_Type(&Otype)=&PyType_Type;
|
||||
if (PyType_Ready(&Otype) < 0) return;
|
||||
if (PyType_Ready(&Itype) < 0) return;
|
||||
PyDict_SetItemString(d,"cStringIO_CAPI",
|
||||
|
|
|
@ -676,8 +676,7 @@ multibytecodec_dealloc(MultibyteCodecObject *self)
|
|||
}
|
||||
|
||||
static PyTypeObject MultibyteCodec_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"MultibyteCodec", /* tp_name */
|
||||
sizeof(MultibyteCodecObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -952,12 +951,11 @@ mbiencoder_dealloc(MultibyteIncrementalEncoderObject *self)
|
|||
{
|
||||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
self->ob_type->tp_free(self);
|
||||
Py_Type(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject MultibyteIncrementalEncoder_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"MultibyteIncrementalEncoder", /* tp_name */
|
||||
sizeof(MultibyteIncrementalEncoderObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1153,12 +1151,11 @@ mbidecoder_dealloc(MultibyteIncrementalDecoderObject *self)
|
|||
{
|
||||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
self->ob_type->tp_free(self);
|
||||
Py_Type(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject MultibyteIncrementalDecoder_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"MultibyteIncrementalDecoder", /* tp_name */
|
||||
sizeof(MultibyteIncrementalDecoderObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1488,12 +1485,11 @@ mbstreamreader_dealloc(MultibyteStreamReaderObject *self)
|
|||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_DECREF(self->stream);
|
||||
self->ob_type->tp_free(self);
|
||||
Py_Type(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static PyTypeObject MultibyteStreamReader_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"MultibyteStreamReader", /* tp_name */
|
||||
sizeof(MultibyteStreamReaderObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1692,7 +1688,7 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self)
|
|||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_DECREF(self->stream);
|
||||
self->ob_type->tp_free(self);
|
||||
Py_Type(self)->tp_free(self);
|
||||
}
|
||||
|
||||
static struct PyMethodDef mbstreamwriter_methods[] = {
|
||||
|
@ -1713,8 +1709,7 @@ static PyMemberDef mbstreamwriter_members[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject MultibyteStreamWriter_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"MultibyteStreamWriter", /* tp_name */
|
||||
sizeof(MultibyteStreamWriterObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -764,7 +764,7 @@ check_tzinfo_subclass(PyObject *p)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"tzinfo argument must be None or of a tzinfo subclass, "
|
||||
"not type '%s'",
|
||||
p->ob_type->tp_name);
|
||||
Py_Type(p)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -855,7 +855,7 @@ call_utc_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg,
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"tzinfo.%s() must return None or "
|
||||
"timedelta, not '%s'",
|
||||
name, u->ob_type->tp_name);
|
||||
name, Py_Type(u)->tp_name);
|
||||
}
|
||||
|
||||
Py_DECREF(u);
|
||||
|
@ -1421,7 +1421,7 @@ cmperror(PyObject *a, PyObject *b)
|
|||
{
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can't compare %s to %s",
|
||||
a->ob_type->tp_name, b->ob_type->tp_name);
|
||||
Py_Type(a)->tp_name, Py_Type(b)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1865,7 +1865,7 @@ accum(const char* tag, PyObject *sofar, PyObject *num, PyObject *factor,
|
|||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"unsupported type for timedelta %s component: %s",
|
||||
tag, num->ob_type->tp_name);
|
||||
tag, Py_Type(num)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2027,7 +2027,7 @@ delta_getstate(PyDateTime_Delta *self)
|
|||
static PyObject *
|
||||
delta_reduce(PyDateTime_Delta* self)
|
||||
{
|
||||
return Py_BuildValue("ON", self->ob_type, delta_getstate(self));
|
||||
return Py_BuildValue("ON", Py_Type(self), delta_getstate(self));
|
||||
}
|
||||
|
||||
#define OFFSET(field) offsetof(PyDateTime_Delta, field)
|
||||
|
@ -2095,8 +2095,7 @@ static PyNumberMethods delta_as_number = {
|
|||
};
|
||||
|
||||
static PyTypeObject PyDateTime_DeltaType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"datetime.timedelta", /* tp_name */
|
||||
sizeof(PyDateTime_Delta), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2504,7 +2503,7 @@ date_replace(PyDateTime_Date *self, PyObject *args, PyObject *kw)
|
|||
tuple = Py_BuildValue("iii", year, month, day);
|
||||
if (tuple == NULL)
|
||||
return NULL;
|
||||
clone = date_new(self->ob_type, tuple, NULL);
|
||||
clone = date_new(Py_Type(self), tuple, NULL);
|
||||
Py_DECREF(tuple);
|
||||
return clone;
|
||||
}
|
||||
|
@ -2635,8 +2634,7 @@ static PyNumberMethods date_as_number = {
|
|||
};
|
||||
|
||||
static PyTypeObject PyDateTime_DateType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"datetime.date", /* tp_name */
|
||||
sizeof(PyDateTime_Date), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2859,10 +2857,10 @@ tzinfo_reduce(PyObject *self)
|
|||
|
||||
if (state == Py_None) {
|
||||
Py_DECREF(state);
|
||||
return Py_BuildValue("(ON)", self->ob_type, args);
|
||||
return Py_BuildValue("(ON)", Py_Type(self), args);
|
||||
}
|
||||
else
|
||||
return Py_BuildValue("(ONN)", self->ob_type, args, state);
|
||||
return Py_BuildValue("(ONN)", Py_Type(self), args, state);
|
||||
}
|
||||
|
||||
static PyMethodDef tzinfo_methods[] = {
|
||||
|
@ -2890,8 +2888,7 @@ static char tzinfo_doc[] =
|
|||
PyDoc_STR("Abstract base class for time zone info objects.");
|
||||
|
||||
static PyTypeObject PyDateTime_TZInfoType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"datetime.tzinfo", /* tp_name */
|
||||
sizeof(PyDateTime_TZInfo), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3056,7 +3053,7 @@ time_dealloc(PyDateTime_Time *self)
|
|||
if (HASTZINFO(self)) {
|
||||
Py_XDECREF(self->tzinfo);
|
||||
}
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3089,7 +3086,7 @@ time_tzname(PyDateTime_Time *self, PyObject *unused) {
|
|||
static PyObject *
|
||||
time_repr(PyDateTime_Time *self)
|
||||
{
|
||||
const char *type_name = self->ob_type->tp_name;
|
||||
const char *type_name = Py_Type(self)->tp_name;
|
||||
int h = TIME_GET_HOUR(self);
|
||||
int m = TIME_GET_MINUTE(self);
|
||||
int s = TIME_GET_SECOND(self);
|
||||
|
@ -3296,7 +3293,7 @@ time_replace(PyDateTime_Time *self, PyObject *args, PyObject *kw)
|
|||
tuple = Py_BuildValue("iiiiO", hh, mm, ss, us, tzinfo);
|
||||
if (tuple == NULL)
|
||||
return NULL;
|
||||
clone = time_new(self->ob_type, tuple, NULL);
|
||||
clone = time_new(Py_Type(self), tuple, NULL);
|
||||
Py_DECREF(tuple);
|
||||
return clone;
|
||||
}
|
||||
|
@ -3350,7 +3347,7 @@ time_getstate(PyDateTime_Time *self)
|
|||
static PyObject *
|
||||
time_reduce(PyDateTime_Time *self, PyObject *arg)
|
||||
{
|
||||
return Py_BuildValue("(ON)", self->ob_type, time_getstate(self));
|
||||
return Py_BuildValue("(ON)", Py_Type(self), time_getstate(self));
|
||||
}
|
||||
|
||||
static PyMethodDef time_methods[] = {
|
||||
|
@ -3400,8 +3397,7 @@ static PyNumberMethods time_as_number = {
|
|||
};
|
||||
|
||||
static PyTypeObject PyDateTime_TimeType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"datetime.time", /* tp_name */
|
||||
sizeof(PyDateTime_Time), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3842,7 +3838,7 @@ datetime_dealloc(PyDateTime_DateTime *self)
|
|||
if (HASTZINFO(self)) {
|
||||
Py_XDECREF(self->tzinfo);
|
||||
}
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3990,7 +3986,7 @@ datetime_subtract(PyObject *left, PyObject *right)
|
|||
static PyObject *
|
||||
datetime_repr(PyDateTime_DateTime *self)
|
||||
{
|
||||
const char *type_name = self->ob_type->tp_name;
|
||||
const char *type_name = Py_Type(self)->tp_name;
|
||||
PyObject *baserepr;
|
||||
|
||||
if (DATE_GET_MICROSECOND(self)) {
|
||||
|
@ -4206,7 +4202,7 @@ datetime_replace(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
|
|||
tuple = Py_BuildValue("iiiiiiiO", y, m, d, hh, mm, ss, us, tzinfo);
|
||||
if (tuple == NULL)
|
||||
return NULL;
|
||||
clone = datetime_new(self->ob_type, tuple, NULL);
|
||||
clone = datetime_new(Py_Type(self), tuple, NULL);
|
||||
Py_DECREF(tuple);
|
||||
return clone;
|
||||
}
|
||||
|
@ -4394,7 +4390,7 @@ datetime_getstate(PyDateTime_DateTime *self)
|
|||
static PyObject *
|
||||
datetime_reduce(PyDateTime_DateTime *self, PyObject *arg)
|
||||
{
|
||||
return Py_BuildValue("(ON)", self->ob_type, datetime_getstate(self));
|
||||
return Py_BuildValue("(ON)", Py_Type(self), datetime_getstate(self));
|
||||
}
|
||||
|
||||
static PyMethodDef datetime_methods[] = {
|
||||
|
@ -4494,8 +4490,7 @@ static PyNumberMethods datetime_as_number = {
|
|||
};
|
||||
|
||||
static PyTypeObject PyDateTime_DateTimeType = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"datetime.datetime", /* tp_name */
|
||||
sizeof(PyDateTime_DateTime), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Dbmtype;
|
||||
|
||||
#define is_dbmobject(v) ((v)->ob_type == &Dbmtype)
|
||||
#define is_dbmobject(v) (Py_Type(v) == &Dbmtype)
|
||||
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
||||
{ PyErr_SetString(DbmError, "DBM object has already been closed"); \
|
||||
return NULL; }
|
||||
|
@ -333,8 +333,7 @@ dbm_getattr(dbmobject *dp, char *name)
|
|||
}
|
||||
|
||||
static PyTypeObject Dbmtype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"dbm.dbm",
|
||||
sizeof(dbmobject),
|
||||
0,
|
||||
|
|
|
@ -62,7 +62,7 @@ dl_sym(dlobject *xp, PyObject *args)
|
|||
name = PyUnicode_AsString(args);
|
||||
} else {
|
||||
PyErr_Format(PyExc_TypeError, "expected string, found %.200s",
|
||||
args->ob_type->tp_name);
|
||||
Py_Type(args)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
func = dlsym(xp->dl_handle, name);
|
||||
|
@ -143,8 +143,7 @@ dl_getattr(dlobject *xp, char *name)
|
|||
|
||||
|
||||
static PyTypeObject Dltype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"dl.dl", /*tp_name*/
|
||||
sizeof(dlobject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -239,7 +238,7 @@ initdl(void)
|
|||
PyObject *m, *d, *x;
|
||||
|
||||
/* Initialize object type */
|
||||
Dltype.ob_type = &PyType_Type;
|
||||
Py_Type(&Dltype) = &PyType_Type;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule("dl", dl_methods);
|
||||
|
|
|
@ -237,7 +237,7 @@ update_refs(PyGC_Head *containers)
|
|||
PyGC_Head *gc = containers->gc.gc_next;
|
||||
for (; gc != containers; gc = gc->gc.gc_next) {
|
||||
assert(gc->gc.gc_refs == GC_REACHABLE);
|
||||
gc->gc.gc_refs = FROM_GC(gc)->ob_refcnt;
|
||||
gc->gc.gc_refs = Py_Refcnt(FROM_GC(gc));
|
||||
/* Python's cyclic gc should never see an incoming refcount
|
||||
* of 0: if something decref'ed to 0, it should have been
|
||||
* deallocated immediately at that time.
|
||||
|
@ -289,7 +289,7 @@ subtract_refs(PyGC_Head *containers)
|
|||
traverseproc traverse;
|
||||
PyGC_Head *gc = containers->gc.gc_next;
|
||||
for (; gc != containers; gc=gc->gc.gc_next) {
|
||||
traverse = FROM_GC(gc)->ob_type->tp_traverse;
|
||||
traverse = Py_Type(FROM_GC(gc))->tp_traverse;
|
||||
(void) traverse(FROM_GC(gc),
|
||||
(visitproc)visit_decref,
|
||||
NULL);
|
||||
|
@ -374,7 +374,7 @@ move_unreachable(PyGC_Head *young, PyGC_Head *unreachable)
|
|||
* the next object to visit.
|
||||
*/
|
||||
PyObject *op = FROM_GC(gc);
|
||||
traverseproc traverse = op->ob_type->tp_traverse;
|
||||
traverseproc traverse = Py_Type(op)->tp_traverse;
|
||||
assert(gc->gc.gc_refs > 0);
|
||||
gc->gc.gc_refs = GC_REACHABLE;
|
||||
(void) traverse(op,
|
||||
|
@ -464,7 +464,7 @@ move_finalizer_reachable(PyGC_Head *finalizers)
|
|||
PyGC_Head *gc = finalizers->gc.gc_next;
|
||||
for (; gc != finalizers; gc = gc->gc.gc_next) {
|
||||
/* Note that the finalizers list may grow during this. */
|
||||
traverse = FROM_GC(gc)->ob_type->tp_traverse;
|
||||
traverse = Py_Type(FROM_GC(gc))->tp_traverse;
|
||||
(void) traverse(FROM_GC(gc),
|
||||
(visitproc)visit_move,
|
||||
(void *)finalizers);
|
||||
|
@ -509,7 +509,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old)
|
|||
assert(IS_TENTATIVELY_UNREACHABLE(op));
|
||||
next = gc->gc.gc_next;
|
||||
|
||||
if (! PyType_SUPPORTS_WEAKREFS(op->ob_type))
|
||||
if (! PyType_SUPPORTS_WEAKREFS(Py_Type(op)))
|
||||
continue;
|
||||
|
||||
/* It supports weakrefs. Does it have any? */
|
||||
|
@ -629,7 +629,7 @@ debug_cycle(char *msg, PyObject *op)
|
|||
{
|
||||
if (debug & DEBUG_OBJECTS) {
|
||||
PySys_WriteStderr("gc: %.100s <%.100s %p>\n",
|
||||
msg, op->ob_type->tp_name, op);
|
||||
msg, Py_Type(op)->tp_name, op);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ delete_garbage(PyGC_Head *collectable, PyGC_Head *old)
|
|||
PyList_Append(garbage, op);
|
||||
}
|
||||
else {
|
||||
if ((clear = op->ob_type->tp_clear) != NULL) {
|
||||
if ((clear = Py_Type(op)->tp_clear) != NULL) {
|
||||
Py_INCREF(op);
|
||||
clear(op);
|
||||
Py_DECREF(op);
|
||||
|
@ -1053,7 +1053,7 @@ gc_referrers_for(PyObject *objs, PyGC_Head *list, PyObject *resultlist)
|
|||
traverseproc traverse;
|
||||
for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) {
|
||||
obj = FROM_GC(gc);
|
||||
traverse = obj->ob_type->tp_traverse;
|
||||
traverse = Py_Type(obj)->tp_traverse;
|
||||
if (obj == objs || obj == resultlist)
|
||||
continue;
|
||||
if (traverse(obj, (visitproc)referrersvisit, objs)) {
|
||||
|
@ -1110,7 +1110,7 @@ gc_get_referents(PyObject *self, PyObject *args)
|
|||
|
||||
if (! PyObject_IS_GC(obj))
|
||||
continue;
|
||||
traverse = obj->ob_type->tp_traverse;
|
||||
traverse = Py_Type(obj)->tp_traverse;
|
||||
if (! traverse)
|
||||
continue;
|
||||
if (traverse(obj, (visitproc)referentsvisit, result)) {
|
||||
|
@ -1332,13 +1332,13 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
|
|||
PyVarObject *
|
||||
_PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
|
||||
{
|
||||
const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems);
|
||||
const size_t basicsize = _PyObject_VAR_SIZE(Py_Type(op), nitems);
|
||||
PyGC_Head *g = AS_GC(op);
|
||||
g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
|
||||
if (g == NULL)
|
||||
return (PyVarObject *)PyErr_NoMemory();
|
||||
op = (PyVarObject *) FROM_GC(g);
|
||||
op->ob_size = nitems;
|
||||
Py_Size(op) = nitems;
|
||||
return op;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Dbmtype;
|
||||
|
||||
#define is_dbmobject(v) ((v)->ob_type == &Dbmtype)
|
||||
#define is_dbmobject(v) (Py_Type(v) == &Dbmtype)
|
||||
#define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \
|
||||
{ PyErr_SetString(DbmError, "GDBM object has already been closed"); \
|
||||
return NULL; }
|
||||
|
@ -393,8 +393,7 @@ dbm_getattr(dbmobject *dp, char *name)
|
|||
}
|
||||
|
||||
static PyTypeObject Dbmtype = {
|
||||
PyObject_HEAD_INIT(0)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(0, 0)
|
||||
"gdbm.gdbm",
|
||||
sizeof(dbmobject),
|
||||
0,
|
||||
|
|
|
@ -59,7 +59,7 @@ groupby_dealloc(groupbyobject *gbo)
|
|||
Py_XDECREF(gbo->tgtkey);
|
||||
Py_XDECREF(gbo->currkey);
|
||||
Py_XDECREF(gbo->currvalue);
|
||||
gbo->ob_type->tp_free(gbo);
|
||||
Py_Type(gbo)->tp_free(gbo);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -139,8 +139,7 @@ PyDoc_STRVAR(groupby_doc,
|
|||
(key, sub-iterator) grouped by each value of key(value).\n");
|
||||
|
||||
static PyTypeObject groupby_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.groupby", /* tp_name */
|
||||
sizeof(groupbyobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -261,8 +260,7 @@ _grouper_next(_grouperobject *igo)
|
|||
}
|
||||
|
||||
static PyTypeObject _grouper_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools._grouper", /* tp_name */
|
||||
sizeof(_grouperobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -415,8 +413,7 @@ teedataobject_dealloc(teedataobject *tdo)
|
|||
PyDoc_STRVAR(teedataobject_doc, "Data container common to multiple tee objects.");
|
||||
|
||||
static PyTypeObject teedataobject_type = {
|
||||
PyObject_HEAD_INIT(0) /* Must fill in type value later */
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */
|
||||
"itertools.tee_dataobject", /* tp_name */
|
||||
sizeof(teedataobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -572,8 +569,7 @@ static PyMethodDef tee_methods[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject tee_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.tee", /* tp_name */
|
||||
sizeof(teeobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -718,7 +714,7 @@ cycle_dealloc(cycleobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->saved);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -768,8 +764,7 @@ Return elements from the iterable until it is exhausted.\n\
|
|||
Then repeat the sequence indefinitely.");
|
||||
|
||||
static PyTypeObject cycle_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.cycle", /* tp_name */
|
||||
sizeof(cycleobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -862,7 +857,7 @@ dropwhile_dealloc(dropwhileobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -882,7 +877,7 @@ dropwhile_next(dropwhileobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *it->ob_type->tp_iternext;
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
for (;;) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -912,8 +907,7 @@ Drop items from the iterable while predicate(item) is true.\n\
|
|||
Afterwards, return every element until the iterable is exhausted.");
|
||||
|
||||
static PyTypeObject dropwhile_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.dropwhile", /* tp_name */
|
||||
sizeof(dropwhileobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1006,7 +1000,7 @@ takewhile_dealloc(takewhileobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1028,7 +1022,7 @@ takewhile_next(takewhileobject *lz)
|
|||
return NULL;
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
item = (*it->ob_type->tp_iternext)(it);
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
if (item == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -1053,8 +1047,7 @@ Return successive entries from an iterable as long as the \n\
|
|||
predicate evaluates to true for each entry.");
|
||||
|
||||
static PyTypeObject takewhile_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.takewhile", /* tp_name */
|
||||
sizeof(takewhileobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1197,7 +1190,7 @@ islice_dealloc(isliceobject *lz)
|
|||
{
|
||||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1216,7 +1209,7 @@ islice_next(isliceobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *it->ob_type->tp_iternext;
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
while (lz->cnt < lz->next) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -1249,8 +1242,7 @@ skipped between successive calls. Works like a slice() on a list\n\
|
|||
but returns an iterator.");
|
||||
|
||||
static PyTypeObject islice_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.islice", /* tp_name */
|
||||
sizeof(isliceobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1341,7 +1333,7 @@ starmap_dealloc(starmapobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1360,7 +1352,7 @@ starmap_next(starmapobject *lz)
|
|||
PyObject *it = lz->it;
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
args = (*it->ob_type->tp_iternext)(it);
|
||||
args = (*Py_Type(it)->tp_iternext)(it);
|
||||
if (args == NULL)
|
||||
return NULL;
|
||||
if (!PyTuple_CheckExact(args)) {
|
||||
|
@ -1381,8 +1373,7 @@ Return an iterator whose values are returned from the function evaluated\n\
|
|||
with a argument tuple taken from the given sequence.");
|
||||
|
||||
static PyTypeObject starmap_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.starmap", /* tp_name */
|
||||
sizeof(starmapobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1487,7 +1478,7 @@ imap_dealloc(imapobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->iters);
|
||||
Py_XDECREF(lz->func);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1561,8 +1552,7 @@ iterable is exhausted instead of filling in None for shorter\n\
|
|||
iterables.");
|
||||
|
||||
static PyTypeObject imap_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.imap", /* tp_name */
|
||||
sizeof(imapobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1666,7 +1656,7 @@ chain_dealloc(chainobject *lz)
|
|||
{
|
||||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->ittuple);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1706,8 +1696,7 @@ first iterable until it is exhausted, then elements from the next\n\
|
|||
iterable, until all of the iterables are exhausted.");
|
||||
|
||||
static PyTypeObject chain_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.chain", /* tp_name */
|
||||
sizeof(chainobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1798,7 +1787,7 @@ ifilter_dealloc(ifilterobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1818,7 +1807,7 @@ ifilter_next(ifilterobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *it->ob_type->tp_iternext;
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
for (;;) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -1850,8 +1839,7 @@ Return those items of sequence for which function(item) is true.\n\
|
|||
If function is None, return the items that are true.");
|
||||
|
||||
static PyTypeObject ifilter_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.ifilter", /* tp_name */
|
||||
sizeof(ifilterobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1943,7 +1931,7 @@ ifilterfalse_dealloc(ifilterfalseobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->func);
|
||||
Py_XDECREF(lz->it);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1963,7 +1951,7 @@ ifilterfalse_next(ifilterfalseobject *lz)
|
|||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
assert(PyIter_Check(it));
|
||||
iternext = *it->ob_type->tp_iternext;
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
for (;;) {
|
||||
item = iternext(it);
|
||||
if (item == NULL)
|
||||
|
@ -1995,8 +1983,7 @@ Return those items of sequence for which function(item) is false.\n\
|
|||
If function is None, return the items that are false.");
|
||||
|
||||
static PyTypeObject ifilterfalse_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.ifilterfalse", /* tp_name */
|
||||
sizeof(ifilterfalseobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2094,8 +2081,7 @@ Return a count object whose .__next__() method returns consecutive\n\
|
|||
integers starting from zero or, if specified, from firstval.");
|
||||
|
||||
static PyTypeObject count_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.count", /* tp_name */
|
||||
sizeof(countobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2214,7 +2200,7 @@ izip_dealloc(izipobject *lz)
|
|||
PyObject_GC_UnTrack(lz);
|
||||
Py_XDECREF(lz->ittuple);
|
||||
Py_XDECREF(lz->result);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2237,12 +2223,12 @@ izip_next(izipobject *lz)
|
|||
|
||||
if (tuplesize == 0)
|
||||
return NULL;
|
||||
if (result->ob_refcnt == 1) {
|
||||
if (Py_Refcnt(result) == 1) {
|
||||
Py_INCREF(result);
|
||||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
assert(PyIter_Check(it));
|
||||
item = (*it->ob_type->tp_iternext)(it);
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
|
@ -2258,7 +2244,7 @@ izip_next(izipobject *lz)
|
|||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
assert(PyIter_Check(it));
|
||||
item = (*it->ob_type->tp_iternext)(it);
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
|
@ -2280,8 +2266,7 @@ function but consumes less memory by returning an iterator instead of\n\
|
|||
a list.");
|
||||
|
||||
static PyTypeObject izip_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.izip", /* tp_name */
|
||||
sizeof(izipobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2365,7 +2350,7 @@ repeat_dealloc(repeatobject *ro)
|
|||
{
|
||||
PyObject_GC_UnTrack(ro);
|
||||
Py_XDECREF(ro->element);
|
||||
ro->ob_type->tp_free(ro);
|
||||
Py_Type(ro)->tp_free(ro);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2418,8 +2403,7 @@ for the specified number of times. If not specified, returns the element\n\
|
|||
endlessly.");
|
||||
|
||||
static PyTypeObject repeat_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.repeat", /* tp_name */
|
||||
sizeof(repeatobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2551,7 +2535,7 @@ izip_longest_dealloc(iziplongestobject *lz)
|
|||
Py_XDECREF(lz->ittuple);
|
||||
Py_XDECREF(lz->result);
|
||||
Py_XDECREF(lz->fillvalue);
|
||||
lz->ob_type->tp_free(lz);
|
||||
Py_Type(lz)->tp_free(lz);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2577,7 +2561,7 @@ izip_longest_next(iziplongestobject *lz)
|
|||
return NULL;
|
||||
if (lz->numactive == 0)
|
||||
return NULL;
|
||||
if (result->ob_refcnt == 1) {
|
||||
if (Py_Refcnt(result) == 1) {
|
||||
Py_INCREF(result);
|
||||
for (i=0 ; i < tuplesize ; i++) {
|
||||
it = PyTuple_GET_ITEM(lz->ittuple, i);
|
||||
|
@ -2586,7 +2570,7 @@ izip_longest_next(iziplongestobject *lz)
|
|||
item = lz->fillvalue;
|
||||
} else {
|
||||
assert(PyIter_Check(it));
|
||||
item = (*it->ob_type->tp_iternext)(it);
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
lz->numactive -= 1;
|
||||
if (lz->numactive == 0) {
|
||||
|
@ -2615,7 +2599,7 @@ izip_longest_next(iziplongestobject *lz)
|
|||
item = lz->fillvalue;
|
||||
} else {
|
||||
assert(PyIter_Check(it));
|
||||
item = (*it->ob_type->tp_iternext)(it);
|
||||
item = (*Py_Type(it)->tp_iternext)(it);
|
||||
if (item == NULL) {
|
||||
lz->numactive -= 1;
|
||||
if (lz->numactive == 0) {
|
||||
|
@ -2647,8 +2631,7 @@ defaults to None or can be specified by a keyword argument.\n\
|
|||
");
|
||||
|
||||
static PyTypeObject iziplongest_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"itertools.izip_longest", /* tp_name */
|
||||
sizeof(iziplongestobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -2747,7 +2730,7 @@ inititertools(void)
|
|||
NULL
|
||||
};
|
||||
|
||||
teedataobject_type.ob_type = &PyType_Type;
|
||||
Py_Type(&teedataobject_type) = &PyType_Type;
|
||||
m = Py_InitModule3("itertools", module_methods, module_doc);
|
||||
if (m == NULL)
|
||||
return;
|
||||
|
|
|
@ -441,8 +441,7 @@ lad_getattr(lad_t *xp, char *name)
|
|||
}
|
||||
|
||||
static PyTypeObject Ladtype = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"linuxaudiodev.linux_audio_device", /*tp_name*/
|
||||
sizeof(lad_t), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
|
@ -229,7 +229,7 @@ loghelper(PyObject* arg, double (*func)(double), char *funcname)
|
|||
log(x) + log(2) * e * SHIFT.
|
||||
CAUTION: e*SHIFT may overflow using int arithmetic,
|
||||
so force use of double. */
|
||||
x = func(x) + (e * (double)SHIFT) * func(2.0);
|
||||
x = func(x) + (e * (double)PyLong_SHIFT) * func(2.0);
|
||||
return PyFloat_FromDouble(x);
|
||||
}
|
||||
|
||||
|
|
|
@ -782,8 +782,7 @@ static PyBufferProcs mmap_as_buffer = {
|
|||
};
|
||||
|
||||
static PyTypeObject mmap_object_type = {
|
||||
PyObject_HEAD_INIT(0) /* patched in module init */
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(0, 0) /* patched in module init */
|
||||
"mmap.mmap", /* tp_name */
|
||||
sizeof(mmap_object), /* tp_size */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -1141,7 +1140,7 @@ PyMODINIT_FUNC
|
|||
PyObject *dict, *module;
|
||||
|
||||
/* Patch the object type */
|
||||
mmap_object_type.ob_type = &PyType_Type;
|
||||
Py_Type(&mmap_object_type) = &PyType_Type;
|
||||
|
||||
module = Py_InitModule("mmap", mmap_functions);
|
||||
if (module == NULL)
|
||||
|
|
|
@ -387,8 +387,7 @@ After, f=itemgetter(2), the call f(r) returns r[2].\n\
|
|||
After, g=itemgetter(2,5,3), the call g(r) returns (r[2], r[5], r[3])");
|
||||
|
||||
static PyTypeObject itemgetter_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"operator.itemgetter", /* tp_name */
|
||||
sizeof(itemgetterobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -525,8 +524,7 @@ After, f=attrgetter('name'), the call f(r) returns r.name.\n\
|
|||
After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).");
|
||||
|
||||
static PyTypeObject attrgetter_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"operator.attrgetter", /* tp_name */
|
||||
sizeof(attrgetterobject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -841,8 +841,7 @@ oss_mixer_getattr(oss_mixer_t *self, char *name)
|
|||
}
|
||||
|
||||
static PyTypeObject OSSAudioType = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"ossaudiodev.oss_audio_device", /*tp_name*/
|
||||
sizeof(oss_audio_t), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -856,8 +855,7 @@ static PyTypeObject OSSAudioType = {
|
|||
};
|
||||
|
||||
static PyTypeObject OSSMixerType = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"ossaudiodev.oss_mixer_device", /*tp_name*/
|
||||
sizeof(oss_mixer_t), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
|
@ -166,8 +166,7 @@ static PyObject *parser_getattr(PyObject *self, char *name);
|
|||
|
||||
static
|
||||
PyTypeObject PyST_Type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"parser.st", /* tp_name */
|
||||
(int) sizeof(PyST_Object), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -694,7 +693,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
|||
PyErr_Format(parser_error,
|
||||
"second item in terminal node must be a string,"
|
||||
" found %s",
|
||||
temp->ob_type->tp_name);
|
||||
Py_Type(temp)->tp_name);
|
||||
Py_DECREF(temp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -707,7 +706,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
|
|||
PyErr_Format(parser_error,
|
||||
"third item in terminal node must be an"
|
||||
" integer, found %s",
|
||||
temp->ob_type->tp_name);
|
||||
Py_Type(temp)->tp_name);
|
||||
Py_DECREF(o);
|
||||
Py_DECREF(temp);
|
||||
return 0;
|
||||
|
@ -3049,7 +3048,7 @@ initparser(void)
|
|||
{
|
||||
PyObject *module, *copyreg;
|
||||
|
||||
PyST_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&PyST_Type) = &PyType_Type;
|
||||
module = Py_InitModule("parser", parser_functions);
|
||||
if (module == NULL)
|
||||
return;
|
||||
|
|
|
@ -2577,7 +2577,7 @@ extract_time(PyObject *t, long* sec, long* usec)
|
|||
long intval;
|
||||
if (PyFloat_Check(t)) {
|
||||
double tval = PyFloat_AsDouble(t);
|
||||
PyObject *intobj = t->ob_type->tp_as_number->nb_int(t);
|
||||
PyObject *intobj = Py_Type(t)->tp_as_number->nb_int(t);
|
||||
if (!intobj)
|
||||
return -1;
|
||||
intval = PyInt_AsLong(intobj);
|
||||
|
|
|
@ -927,7 +927,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
|
|||
if (!PyString_Check(str)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"read() did not return a string object (type=%.400s)",
|
||||
str->ob_type->tp_name);
|
||||
Py_Type(str)->tp_name);
|
||||
goto finally;
|
||||
}
|
||||
len = PyString_GET_SIZE(str);
|
||||
|
@ -1621,8 +1621,7 @@ xmlparse_clear(xmlparseobject *op)
|
|||
PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser");
|
||||
|
||||
static PyTypeObject Xmlparsetype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"pyexpat.xmlparser", /*tp_name*/
|
||||
sizeof(xmlparseobject) + PyGC_HEAD_SIZE,/*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -1790,7 +1789,7 @@ MODULE_INITFUNC(void)
|
|||
if (modelmod_name == NULL)
|
||||
return;
|
||||
|
||||
Xmlparsetype.ob_type = &PyType_Type;
|
||||
Py_Type(&Xmlparsetype) = &PyType_Type;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
m = Py_InitModule3(MODULE_NAME, pyexpat_methods,
|
||||
|
|
|
@ -587,8 +587,7 @@ poll_getattr(pollObject *self, char *name)
|
|||
static PyTypeObject poll_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"select.poll", /*tp_name*/
|
||||
sizeof(pollObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -706,7 +705,7 @@ initselect(void)
|
|||
#else
|
||||
{
|
||||
#endif
|
||||
poll_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&poll_Type) = &PyType_Type;
|
||||
PyModule_AddIntConstant(m, "POLLIN", POLLIN);
|
||||
PyModule_AddIntConstant(m, "POLLPRI", POLLPRI);
|
||||
PyModule_AddIntConstant(m, "POLLOUT", POLLOUT);
|
||||
|
|
|
@ -409,7 +409,7 @@ SHA256_copy(SHAobject *self, PyObject *unused)
|
|||
{
|
||||
SHAobject *newobj;
|
||||
|
||||
if (((PyObject*)self)->ob_type == &SHA256type) {
|
||||
if (Py_Type(self) == &SHA256type) {
|
||||
if ( (newobj = newSHA256object())==NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
|
@ -536,8 +536,7 @@ static PyMemberDef SHA_members[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject SHA224type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_sha256.sha224", /*tp_name*/
|
||||
sizeof(SHAobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -571,8 +570,7 @@ static PyTypeObject SHA224type = {
|
|||
};
|
||||
|
||||
static PyTypeObject SHA256type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_sha256.sha256", /*tp_name*/
|
||||
sizeof(SHAobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -689,10 +687,10 @@ init_sha256(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
SHA224type.ob_type = &PyType_Type;
|
||||
Py_Type(&SHA224type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA224type) < 0)
|
||||
return;
|
||||
SHA256type.ob_type = &PyType_Type;
|
||||
Py_Type(&SHA256type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA256type) < 0)
|
||||
return;
|
||||
m = Py_InitModule("_sha256", SHA_functions);
|
||||
|
|
|
@ -602,8 +602,7 @@ static PyMemberDef SHA_members[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject SHA384type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_sha512.sha384", /*tp_name*/
|
||||
sizeof(SHAobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -637,8 +636,7 @@ static PyTypeObject SHA384type = {
|
|||
};
|
||||
|
||||
static PyTypeObject SHA512type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_sha512.sha512", /*tp_name*/
|
||||
sizeof(SHAobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -755,10 +753,10 @@ init_sha512(void)
|
|||
{
|
||||
PyObject *m;
|
||||
|
||||
SHA384type.ob_type = &PyType_Type;
|
||||
Py_Type(&SHA384type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA384type) < 0)
|
||||
return;
|
||||
SHA512type.ob_type = &PyType_Type;
|
||||
Py_Type(&SHA512type) = &PyType_Type;
|
||||
if (PyType_Ready(&SHA512type) < 0)
|
||||
return;
|
||||
m = Py_InitModule("_sha512", SHA_functions);
|
||||
|
|
|
@ -1247,7 +1247,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_NETLINK address must be tuple, not %.500s",
|
||||
args->ob_type->tp_name);
|
||||
Py_Type(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &pid, &groups))
|
||||
|
@ -1270,7 +1270,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_INET address must be tuple, not %.500s",
|
||||
args->ob_type->tp_name);
|
||||
Py_Type(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "eti:getsockaddrarg",
|
||||
|
@ -1300,7 +1300,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_INET6 address must be tuple, not %.500s",
|
||||
args->ob_type->tp_name);
|
||||
Py_Type(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "eti|ii",
|
||||
|
@ -1422,7 +1422,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
PyExc_TypeError,
|
||||
"getsockaddrarg: "
|
||||
"AF_PACKET address must be tuple, not %.500s",
|
||||
args->ob_type->tp_name);
|
||||
Py_Type(args)->tp_name);
|
||||
return 0;
|
||||
}
|
||||
if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName,
|
||||
|
@ -2771,7 +2771,7 @@ sock_dealloc(PySocketSockObject *s)
|
|||
{
|
||||
if (s->sock_fd != -1)
|
||||
(void) SOCKETCLOSE(s->sock_fd);
|
||||
s->ob_type->tp_free((PyObject *)s);
|
||||
Py_Type(s)->tp_free((PyObject *)s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2861,8 +2861,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
/* Type object for socket objects. */
|
||||
|
||||
static PyTypeObject sock_type = {
|
||||
PyObject_HEAD_INIT(0) /* Must fill in type value later */
|
||||
0, /* ob_size */
|
||||
PyVarObject_HEAD_INIT(0, 0) /* Must fill in type value later */
|
||||
"_socket.socket", /* tp_name */
|
||||
sizeof(PySocketSockObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
|
@ -3445,7 +3444,7 @@ socket_ntohl(PyObject *self, PyObject *arg)
|
|||
else
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"expected int/long, %s found",
|
||||
arg->ob_type->tp_name);
|
||||
Py_Type(arg)->tp_name);
|
||||
if (x == (unsigned long) -1 && PyErr_Occurred())
|
||||
return NULL;
|
||||
return PyLong_FromUnsignedLong(ntohl(x));
|
||||
|
@ -3504,7 +3503,7 @@ socket_htonl(PyObject *self, PyObject *arg)
|
|||
else
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"expected int/long, %s found",
|
||||
arg->ob_type->tp_name);
|
||||
Py_Type(arg)->tp_name);
|
||||
return PyLong_FromUnsignedLong(htonl((unsigned long)x));
|
||||
}
|
||||
|
||||
|
@ -4142,7 +4141,7 @@ init_socket(void)
|
|||
if (!os_init())
|
||||
return;
|
||||
|
||||
sock_type.ob_type = &PyType_Type;
|
||||
Py_Type(&sock_type) = &PyType_Type;
|
||||
m = Py_InitModule3(PySocket_MODULE_NAME,
|
||||
socket_methods,
|
||||
socket_doc);
|
||||
|
|
|
@ -42,8 +42,8 @@ static sadstatusobject *sads_alloc(void); /* Forward */
|
|||
|
||||
static PyObject *SunAudioError;
|
||||
|
||||
#define is_sadobject(v) ((v)->ob_type == &Sadtype)
|
||||
#define is_sadstatusobject(v) ((v)->ob_type == &Sadstatustype)
|
||||
#define is_sadobject(v) (Py_Type(v) == &Sadtype)
|
||||
#define is_sadstatusobject(v) (Py_Type(v) == &Sadstatustype)
|
||||
|
||||
|
||||
static sadobject *
|
||||
|
@ -409,8 +409,7 @@ sads_setattr(sadstatusobject *xp, char *name, PyObject *v)
|
|||
|
||||
|
||||
static PyTypeObject Sadtype = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"sunaudiodev.sun_audio_device", /*tp_name*/
|
||||
sizeof(sadobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -424,8 +423,7 @@ static PyTypeObject Sadtype = {
|
|||
};
|
||||
|
||||
static PyTypeObject Sadstatustype = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"sunaudiodev.sun_audio_device_status", /*tp_name*/
|
||||
sizeof(sadstatusobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
|
@ -126,8 +126,7 @@ lock_getattr(lockobject *self, char *name)
|
|||
}
|
||||
|
||||
static PyTypeObject Locktype = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"thread.lock", /*tp_name*/
|
||||
sizeof(lockobject), /*tp_size*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -251,7 +250,7 @@ local_dealloc(localobject *self)
|
|||
}
|
||||
|
||||
local_clear(self);
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
Py_Type(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -283,8 +282,8 @@ _ldict(localobject *self)
|
|||
Py_INCREF(ldict);
|
||||
self->dict = ldict; /* still borrowed */
|
||||
|
||||
if (self->ob_type->tp_init != PyBaseObject_Type.tp_init &&
|
||||
self->ob_type->tp_init((PyObject*)self,
|
||||
if (Py_Type(self)->tp_init != PyBaseObject_Type.tp_init &&
|
||||
Py_Type(self)->tp_init((PyObject*)self,
|
||||
self->args, self->kw) < 0) {
|
||||
/* we need to get rid of ldict from thread so
|
||||
we create a new one the next time we do an attr
|
||||
|
@ -336,8 +335,7 @@ static PyGetSetDef local_getset[] = {
|
|||
static PyObject *local_getattro(localobject *, PyObject *);
|
||||
|
||||
static PyTypeObject localtype = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
/* ob_size */ 0,
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
/* tp_name */ "thread._local",
|
||||
/* tp_basicsize */ sizeof(localobject),
|
||||
/* tp_itemsize */ 0,
|
||||
|
@ -388,7 +386,7 @@ local_getattro(localobject *self, PyObject *name)
|
|||
if (ldict == NULL)
|
||||
return NULL;
|
||||
|
||||
if (self->ob_type != &localtype)
|
||||
if (Py_Type(self) != &localtype)
|
||||
/* use generic lookup for subtypes */
|
||||
return PyObject_GenericGetAttr((PyObject *)self, name);
|
||||
|
||||
|
|
|
@ -1134,8 +1134,7 @@ static PyMethodDef unicodedata_functions[] = {
|
|||
static PyTypeObject UCD_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"unicodedata.UCD", /*tp_name*/
|
||||
sizeof(PreviousDBVersion), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -1193,7 +1192,7 @@ initunicodedata(void)
|
|||
{
|
||||
PyObject *m, *v;
|
||||
|
||||
UCD_Type.ob_type = &PyType_Type;
|
||||
Py_Type(&UCD_Type) = &PyType_Type;
|
||||
|
||||
m = Py_InitModule3(
|
||||
"unicodedata", unicodedata_functions, unicodedata_docstring);
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct {
|
|||
|
||||
static PyTypeObject Xxo_Type;
|
||||
|
||||
#define XxoObject_Check(v) ((v)->ob_type == &Xxo_Type)
|
||||
#define XxoObject_Check(v) (Py_Type(v) == &Xxo_Type)
|
||||
|
||||
static XxoObject *
|
||||
newXxoObject(PyObject *arg)
|
||||
|
@ -97,8 +97,7 @@ Xxo_setattr(XxoObject *self, char *name, PyObject *v)
|
|||
static PyTypeObject Xxo_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"xxmodule.Xxo", /*tp_name*/
|
||||
sizeof(XxoObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -216,8 +215,7 @@ xx_roj(PyObject *self, PyObject *args)
|
|||
static PyTypeObject Str_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"xxmodule.Str", /*tp_name*/
|
||||
0, /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
@ -272,8 +270,7 @@ null_richcompare(PyObject *self, PyObject *other, int op)
|
|||
static PyTypeObject Null_Type = {
|
||||
/* The ob_type field must be initialized in the module init function
|
||||
* to be portable to Windows without using C++. */
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"xxmodule.Null", /*tp_name*/
|
||||
0, /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
|
@ -101,8 +101,7 @@ static PyGetSetDef spamlist_getsets[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject spamlist_type = {
|
||||
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
|
||||
"xxsubtype.spamlist",
|
||||
sizeof(spamlistobject),
|
||||
0,
|
||||
|
@ -193,8 +192,7 @@ static PyMemberDef spamdict_members[] = {
|
|||
};
|
||||
|
||||
static PyTypeObject spamdict_type = {
|
||||
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
|
||||
"xxsubtype.spamdict",
|
||||
sizeof(spamdictobject),
|
||||
0,
|
||||
|
|
|
@ -181,7 +181,7 @@ zipimporter_dealloc(ZipImporter *self)
|
|||
Py_XDECREF(self->archive);
|
||||
Py_XDECREF(self->prefix);
|
||||
Py_XDECREF(self->files);
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -557,8 +557,7 @@ a valid Zip archive.");
|
|||
#define DEFERRED_ADDRESS(ADDR) 0
|
||||
|
||||
static PyTypeObject ZipImporter_Type = {
|
||||
PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
|
||||
"zipimport.zipimporter",
|
||||
sizeof(ZipImporter),
|
||||
0, /* tp_itemsize */
|
||||
|
|
|
@ -961,8 +961,7 @@ static PyMethodDef zlib_methods[] =
|
|||
};
|
||||
|
||||
static PyTypeObject Comptype = {
|
||||
PyObject_HEAD_INIT(0)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(0, 0)
|
||||
"zlib.Compress",
|
||||
sizeof(compobject),
|
||||
0,
|
||||
|
@ -978,8 +977,7 @@ static PyTypeObject Comptype = {
|
|||
};
|
||||
|
||||
static PyTypeObject Decomptype = {
|
||||
PyObject_HEAD_INIT(0)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(0, 0)
|
||||
"zlib.Decompress",
|
||||
sizeof(compobject),
|
||||
0,
|
||||
|
@ -1013,8 +1011,8 @@ PyMODINIT_FUNC
|
|||
PyInit_zlib(void)
|
||||
{
|
||||
PyObject *m, *ver;
|
||||
Comptype.ob_type = &PyType_Type;
|
||||
Decomptype.ob_type = &PyType_Type;
|
||||
Py_Type(&Comptype) = &PyType_Type;
|
||||
Py_Type(&Decomptype) = &PyType_Type;
|
||||
m = Py_InitModule4("zlib", zlib_methods,
|
||||
zlib_module_documentation,
|
||||
(PyObject*)NULL,PYTHON_API_VERSION);
|
||||
|
|
|
@ -143,8 +143,7 @@ static PyNumberMethods bool_as_number = {
|
|||
/* The type object for bool. Note that this cannot be subclassed! */
|
||||
|
||||
PyTypeObject PyBool_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"bool",
|
||||
sizeof(struct _longobject),
|
||||
0,
|
||||
|
@ -188,11 +187,11 @@ PyTypeObject PyBool_Type = {
|
|||
|
||||
/* Named Zero for link-level compatibility */
|
||||
struct _longobject _Py_FalseStruct = {
|
||||
PyObject_HEAD_INIT(&PyBool_Type)
|
||||
0, { 0 }
|
||||
PyVarObject_HEAD_INIT(&PyBool_Type, 0)
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
struct _longobject _Py_TrueStruct = {
|
||||
PyObject_HEAD_INIT(&PyBool_Type)
|
||||
1, { 1 }
|
||||
PyVarObject_HEAD_INIT(&PyBool_Type, 1)
|
||||
{ 1 }
|
||||
};
|
||||
|
|
|
@ -710,8 +710,7 @@ static PyBufferProcs buffer_as_buffer = {
|
|||
};
|
||||
|
||||
PyTypeObject PyBuffer_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"buffer",
|
||||
sizeof(PyBufferObject),
|
||||
0,
|
||||
|
|
|
@ -25,7 +25,7 @@ PyBytes_Init(void)
|
|||
if (nullbytes == NULL)
|
||||
return 0;
|
||||
nullbytes->ob_bytes = NULL;
|
||||
nullbytes->ob_size = nullbytes->ob_alloc = 0;
|
||||
Py_Size(nullbytes) = nullbytes->ob_alloc = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ _getbytevalue(PyObject* arg, int *value)
|
|||
Py_ssize_t
|
||||
_getbuffer(PyObject *obj, void **ptr)
|
||||
{
|
||||
PyBufferProcs *buffer = obj->ob_type->tp_as_buffer;
|
||||
PyBufferProcs *buffer = Py_Type(obj)->tp_as_buffer;
|
||||
|
||||
if (buffer == NULL ||
|
||||
PyUnicode_Check(obj) ||
|
||||
|
@ -142,7 +142,7 @@ PyBytes_Resize(PyObject *self, Py_ssize_t size)
|
|||
}
|
||||
else if (size < alloc) {
|
||||
/* Within allocated size; quick exit */
|
||||
((PyBytesObject *)self)->ob_size = size;
|
||||
Py_Size(self) = size;
|
||||
((PyBytesObject *)self)->ob_bytes[size] = '\0'; /* Trailing null byte */
|
||||
return 0;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ PyBytes_Resize(PyObject *self, Py_ssize_t size)
|
|||
}
|
||||
|
||||
((PyBytesObject *)self)->ob_bytes = sval;
|
||||
((PyBytesObject *)self)->ob_size = size;
|
||||
Py_Size(self) = size;
|
||||
((PyBytesObject *)self)->ob_alloc = alloc;
|
||||
((PyBytesObject *)self)->ob_bytes[size] = '\0'; /* Trailing null byte */
|
||||
|
||||
|
@ -180,7 +180,7 @@ PyBytes_Concat(PyObject *a, PyObject *b)
|
|||
bsize = _getbuffer(b, &bptr);
|
||||
if (asize < 0 || bsize < 0) {
|
||||
PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s",
|
||||
a->ob_type->tp_name, b->ob_type->tp_name);
|
||||
Py_Type(a)->tp_name, Py_Type(b)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ PyBytes_Concat(PyObject *a, PyObject *b)
|
|||
static Py_ssize_t
|
||||
bytes_length(PyBytesObject *self)
|
||||
{
|
||||
return self->ob_size;
|
||||
return Py_Size(self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -222,16 +222,16 @@ bytes_iconcat(PyBytesObject *self, PyObject *other)
|
|||
osize = _getbuffer(other, &optr);
|
||||
if (osize < 0) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can't concat bytes to %.100s", other->ob_type->tp_name);
|
||||
"can't concat bytes to %.100s", Py_Type(other)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mysize = self->ob_size;
|
||||
mysize = Py_Size(self);
|
||||
size = mysize + osize;
|
||||
if (size < 0)
|
||||
return PyErr_NoMemory();
|
||||
if (size < self->ob_alloc) {
|
||||
self->ob_size = size;
|
||||
Py_Size(self) = size;
|
||||
self->ob_bytes[self->ob_size] = '\0'; /* Trailing null byte */
|
||||
}
|
||||
else if (PyBytes_Resize((PyObject *)self, size) < 0)
|
||||
|
@ -250,7 +250,7 @@ bytes_repeat(PyBytesObject *self, Py_ssize_t count)
|
|||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
mysize = self->ob_size;
|
||||
mysize = Py_Size(self);
|
||||
size = mysize * count;
|
||||
if (count != 0 && size / count != mysize)
|
||||
return PyErr_NoMemory();
|
||||
|
@ -275,12 +275,12 @@ bytes_irepeat(PyBytesObject *self, Py_ssize_t count)
|
|||
|
||||
if (count < 0)
|
||||
count = 0;
|
||||
mysize = self->ob_size;
|
||||
mysize = Py_Size(self);
|
||||
size = mysize * count;
|
||||
if (count != 0 && size / count != mysize)
|
||||
return PyErr_NoMemory();
|
||||
if (size < self->ob_alloc) {
|
||||
self->ob_size = size;
|
||||
Py_Size(self) = size;
|
||||
self->ob_bytes[self->ob_size] = '\0'; /* Trailing null byte */
|
||||
}
|
||||
else if (PyBytes_Resize((PyObject *)self, size) < 0)
|
||||
|
@ -303,15 +303,15 @@ bytes_substring(PyBytesObject *self, PyBytesObject *other)
|
|||
{
|
||||
Py_ssize_t i;
|
||||
|
||||
if (other->ob_size == 1) {
|
||||
if (Py_Size(other) == 1) {
|
||||
return memchr(self->ob_bytes, other->ob_bytes[0],
|
||||
self->ob_size) != NULL;
|
||||
Py_Size(self)) != NULL;
|
||||
}
|
||||
if (other->ob_size == 0)
|
||||
if (Py_Size(other) == 0)
|
||||
return 1; /* Edge case */
|
||||
for (i = 0; i + other->ob_size <= self->ob_size; i++) {
|
||||
for (i = 0; i + Py_Size(other) <= Py_Size(self); i++) {
|
||||
/* XXX Yeah, yeah, lots of optimizations possible... */
|
||||
if (memcmp(self->ob_bytes + i, other->ob_bytes, other->ob_size) == 0)
|
||||
if (memcmp(self->ob_bytes + i, other->ob_bytes, Py_Size(other)) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -333,15 +333,15 @@ bytes_contains(PyBytesObject *self, PyObject *value)
|
|||
return -1;
|
||||
}
|
||||
|
||||
return memchr(self->ob_bytes, ival, self->ob_size) != NULL;
|
||||
return memchr(self->ob_bytes, ival, Py_Size(self)) != NULL;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
bytes_getitem(PyBytesObject *self, Py_ssize_t i)
|
||||
{
|
||||
if (i < 0)
|
||||
i += self->ob_size;
|
||||
if (i < 0 || i >= self->ob_size) {
|
||||
i += Py_Size(self);
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "bytes index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ bytes_subscript(PyBytesObject *self, PyObject *item)
|
|||
if (i < 0)
|
||||
i += PyBytes_GET_SIZE(self);
|
||||
|
||||
if (i < 0 || i >= self->ob_size) {
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "bytes index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi,
|
|||
if (needed < 0) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"can't set bytes slice from %.100s",
|
||||
values->ob_type->tp_name);
|
||||
Py_Type(values)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -439,8 +439,8 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi,
|
|||
lo = 0;
|
||||
if (hi < lo)
|
||||
hi = lo;
|
||||
if (hi > self->ob_size)
|
||||
hi = self->ob_size;
|
||||
if (hi > Py_Size(self))
|
||||
hi = Py_Size(self);
|
||||
|
||||
avail = hi - lo;
|
||||
if (avail < 0)
|
||||
|
@ -455,10 +455,10 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi,
|
|||
0 lo new_hi new_size
|
||||
*/
|
||||
memmove(self->ob_bytes + lo + needed, self->ob_bytes + hi,
|
||||
self->ob_size - hi);
|
||||
Py_Size(self) - hi);
|
||||
}
|
||||
if (PyBytes_Resize((PyObject *)self,
|
||||
self->ob_size + needed - avail) < 0)
|
||||
Py_Size(self) + needed - avail) < 0)
|
||||
return -1;
|
||||
if (avail < needed) {
|
||||
/*
|
||||
|
@ -468,7 +468,7 @@ bytes_setslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi,
|
|||
0 lo new_hi new_size
|
||||
*/
|
||||
memmove(self->ob_bytes + lo + needed, self->ob_bytes + hi,
|
||||
self->ob_size - lo - needed);
|
||||
Py_Size(self) - lo - needed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,9 +484,9 @@ bytes_setitem(PyBytesObject *self, Py_ssize_t i, PyObject *value)
|
|||
Py_ssize_t ival;
|
||||
|
||||
if (i < 0)
|
||||
i += self->ob_size;
|
||||
i += Py_Size(self);
|
||||
|
||||
if (i < 0 || i >= self->ob_size) {
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "bytes index out of range");
|
||||
return -1;
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
|
|||
if (i < 0)
|
||||
i += PyBytes_GET_SIZE(self);
|
||||
|
||||
if (i < 0 || i >= self->ob_size) {
|
||||
if (i < 0 || i >= Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "bytes index out of range");
|
||||
return -1;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
|
|||
else {
|
||||
assert(PyBytes_Check(values));
|
||||
bytes = ((PyBytesObject *)values)->ob_bytes;
|
||||
needed = ((PyBytesObject *)values)->ob_size;
|
||||
needed = Py_Size(values);
|
||||
}
|
||||
/* Make sure b[5:2] = ... inserts before 5, not before 2. */
|
||||
if ((step < 0 && start < stop) ||
|
||||
|
@ -592,10 +592,10 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
|
|||
0 lo new_hi new_size
|
||||
*/
|
||||
memmove(self->ob_bytes + start + needed, self->ob_bytes + stop,
|
||||
self->ob_size - stop);
|
||||
Py_Size(self) - stop);
|
||||
}
|
||||
if (PyBytes_Resize((PyObject *)self,
|
||||
self->ob_size + needed - slicelen) < 0)
|
||||
Py_Size(self) + needed - slicelen) < 0)
|
||||
return -1;
|
||||
if (slicelen < needed) {
|
||||
/*
|
||||
|
@ -605,7 +605,7 @@ bytes_ass_subscript(PyBytesObject *self, PyObject *item, PyObject *values)
|
|||
0 lo new_hi new_size
|
||||
*/
|
||||
memmove(self->ob_bytes + start + needed, self->ob_bytes + stop,
|
||||
self->ob_size - start - needed);
|
||||
Py_Size(self) - start - needed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -676,7 +676,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds)
|
|||
PyObject *it;
|
||||
PyObject *(*iternext)(PyObject *);
|
||||
|
||||
if (self->ob_size != 0) {
|
||||
if (Py_Size(self) != 0) {
|
||||
/* Empty previous contents (yes, do this first of all!) */
|
||||
if (PyBytes_Resize((PyObject *)self, 0) < 0)
|
||||
return -1;
|
||||
|
@ -708,7 +708,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds)
|
|||
if (!PyBytes_Check(encoded) && !PyString_Check(encoded)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder did not return a str8 or bytes object (type=%.400s)",
|
||||
encoded->ob_type->tp_name);
|
||||
Py_Type(encoded)->tp_name);
|
||||
Py_DECREF(encoded);
|
||||
return -1;
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds)
|
|||
it = PyObject_GetIter(arg);
|
||||
if (it == NULL)
|
||||
return -1;
|
||||
iternext = *it->ob_type->tp_iternext;
|
||||
iternext = *Py_Type(it)->tp_iternext;
|
||||
|
||||
/* Run the iterator to exhaustion */
|
||||
for (;;) {
|
||||
|
@ -793,11 +793,11 @@ bytes_init(PyBytesObject *self, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
|
||||
/* Append the byte */
|
||||
if (self->ob_size < self->ob_alloc)
|
||||
self->ob_size++;
|
||||
else if (PyBytes_Resize((PyObject *)self, self->ob_size+1) < 0)
|
||||
if (Py_Size(self) < self->ob_alloc)
|
||||
Py_Size(self)++;
|
||||
else if (PyBytes_Resize((PyObject *)self, Py_Size(self)+1) < 0)
|
||||
goto error;
|
||||
self->ob_bytes[self->ob_size-1] = value;
|
||||
self->ob_bytes[Py_Size(self)-1] = value;
|
||||
}
|
||||
|
||||
/* Clean up and return success */
|
||||
|
@ -818,7 +818,7 @@ bytes_repr(PyBytesObject *self)
|
|||
static const char *hexdigits = "0123456789abcdef";
|
||||
size_t newsize = 3 + 4 * self->ob_size;
|
||||
PyObject *v;
|
||||
if (newsize > PY_SSIZE_T_MAX || newsize / 4 != self->ob_size) {
|
||||
if (newsize > PY_SSIZE_T_MAX || newsize / 4 != Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"bytes object is too large to make repr");
|
||||
return NULL;
|
||||
|
@ -836,7 +836,7 @@ bytes_repr(PyBytesObject *self)
|
|||
p = PyUnicode_AS_UNICODE(v);
|
||||
*p++ = 'b';
|
||||
*p++ = quote;
|
||||
for (i = 0; i < self->ob_size; i++) {
|
||||
for (i = 0; i < Py_Size(self); i++) {
|
||||
/* There's at least enough room for a hex escape
|
||||
and a closing quote. */
|
||||
assert(newsize - (p - PyUnicode_AS_UNICODE(v)) >= 5);
|
||||
|
@ -874,7 +874,7 @@ bytes_repr(PyBytesObject *self)
|
|||
static PyObject *
|
||||
bytes_str(PyBytesObject *self)
|
||||
{
|
||||
return PyString_FromStringAndSize(self->ob_bytes, self->ob_size);
|
||||
return PyString_FromStringAndSize(self->ob_bytes, Py_Size(self));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -941,7 +941,7 @@ bytes_dealloc(PyBytesObject *self)
|
|||
if (self->ob_bytes != 0) {
|
||||
PyMem_Free(self->ob_bytes);
|
||||
}
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
Py_Type(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
|
@ -956,14 +956,14 @@ bytes_getbuffer(PyBytesObject *self, Py_ssize_t index, const void **ptr)
|
|||
*ptr = "";
|
||||
else
|
||||
*ptr = self->ob_bytes;
|
||||
return self->ob_size;
|
||||
return Py_Size(self);
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
bytes_getsegcount(PyStringObject *self, Py_ssize_t *lenp)
|
||||
{
|
||||
if (lenp)
|
||||
*lenp = self->ob_size;
|
||||
*lenp = Py_Size(self);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2043,7 +2043,7 @@ bytes_replace(PyBytesObject *self, PyObject *args)
|
|||
count++; }
|
||||
|
||||
/* Always force the list to the expected size. */
|
||||
#define FIX_PREALLOC_SIZE(list) ((PyListObject *)list)->ob_size = count
|
||||
#define FIX_PREALLOC_SIZE(list) Py_Size(list) = count
|
||||
|
||||
|
||||
Py_LOCAL_INLINE(PyObject *)
|
||||
|
@ -2307,7 +2307,7 @@ end of the bytes.");
|
|||
static PyObject *
|
||||
bytes_extend(PyBytesObject *self, PyObject *arg)
|
||||
{
|
||||
if (bytes_setslice(self, self->ob_size, self->ob_size, arg) == -1)
|
||||
if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
|
||||
return NULL;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
@ -2321,7 +2321,7 @@ static PyObject *
|
|||
bytes_reverse(PyBytesObject *self, PyObject *unused)
|
||||
{
|
||||
char swap, *head, *tail;
|
||||
Py_ssize_t i, j, n = self->ob_size;
|
||||
Py_ssize_t i, j, n = Py_Size(self);
|
||||
|
||||
j = n / 2;
|
||||
head = self->ob_bytes;
|
||||
|
@ -2343,7 +2343,7 @@ static PyObject *
|
|||
bytes_insert(PyBytesObject *self, PyObject *args)
|
||||
{
|
||||
int value;
|
||||
Py_ssize_t where, n = self->ob_size;
|
||||
Py_ssize_t where, n = Py_Size(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ni:insert", &where, &value))
|
||||
return NULL;
|
||||
|
@ -2382,7 +2382,7 @@ static PyObject *
|
|||
bytes_append(PyBytesObject *self, PyObject *arg)
|
||||
{
|
||||
int value;
|
||||
Py_ssize_t n = self->ob_size;
|
||||
Py_ssize_t n = Py_Size(self);
|
||||
|
||||
if (! _getbytevalue(arg, &value))
|
||||
return NULL;
|
||||
|
@ -2408,7 +2408,7 @@ static PyObject *
|
|||
bytes_pop(PyBytesObject *self, PyObject *args)
|
||||
{
|
||||
int value;
|
||||
Py_ssize_t where = -1, n = self->ob_size;
|
||||
Py_ssize_t where = -1, n = Py_Size(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|n:pop", &where))
|
||||
return NULL;
|
||||
|
@ -2419,8 +2419,8 @@ bytes_pop(PyBytesObject *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
if (where < 0)
|
||||
where += self->ob_size;
|
||||
if (where < 0 || where >= self->ob_size) {
|
||||
where += Py_Size(self);
|
||||
if (where < 0 || where >= Py_Size(self)) {
|
||||
PyErr_SetString(PyExc_IndexError, "pop index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2441,7 +2441,7 @@ static PyObject *
|
|||
bytes_remove(PyBytesObject *self, PyObject *arg)
|
||||
{
|
||||
int value;
|
||||
Py_ssize_t where, n = self->ob_size;
|
||||
Py_ssize_t where, n = Py_Size(self);
|
||||
|
||||
if (! _getbytevalue(arg, &value))
|
||||
return NULL;
|
||||
|
@ -2498,9 +2498,9 @@ bytes_strip(PyBytesObject *self, PyObject *arg)
|
|||
return NULL;
|
||||
}
|
||||
myptr = self->ob_bytes;
|
||||
mysize = self->ob_size;
|
||||
mysize = Py_Size(self);
|
||||
argptr = ((PyBytesObject *)arg)->ob_bytes;
|
||||
argsize = ((PyBytesObject *)arg)->ob_size;
|
||||
argsize = Py_Size(arg);
|
||||
left = lstrip_helper(myptr, mysize, argptr, argsize);
|
||||
right = rstrip_helper(myptr, mysize, argptr, argsize);
|
||||
return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left);
|
||||
|
@ -2520,9 +2520,9 @@ bytes_lstrip(PyBytesObject *self, PyObject *arg)
|
|||
return NULL;
|
||||
}
|
||||
myptr = self->ob_bytes;
|
||||
mysize = self->ob_size;
|
||||
mysize = Py_Size(self);
|
||||
argptr = ((PyBytesObject *)arg)->ob_bytes;
|
||||
argsize = ((PyBytesObject *)arg)->ob_size;
|
||||
argsize = Py_Size(arg);
|
||||
left = lstrip_helper(myptr, mysize, argptr, argsize);
|
||||
right = mysize;
|
||||
return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left);
|
||||
|
@ -2542,9 +2542,9 @@ bytes_rstrip(PyBytesObject *self, PyObject *arg)
|
|||
return NULL;
|
||||
}
|
||||
myptr = self->ob_bytes;
|
||||
mysize = self->ob_size;
|
||||
mysize = Py_Size(self);
|
||||
argptr = ((PyBytesObject *)arg)->ob_bytes;
|
||||
argsize = ((PyBytesObject *)arg)->ob_size;
|
||||
argsize = Py_Size(arg);
|
||||
left = 0;
|
||||
right = rstrip_helper(myptr, mysize, argptr, argsize);
|
||||
return PyBytes_FromStringAndSize(self->ob_bytes + left, right - left);
|
||||
|
@ -2616,7 +2616,7 @@ bytes_join(PyBytesObject *self, PyObject *it)
|
|||
"can only join an iterable of bytes "
|
||||
"(item %ld has type '%.100s')",
|
||||
/* XXX %ld isn't right on Win64 */
|
||||
(long)i, obj->ob_type->tp_name);
|
||||
(long)i, Py_Type(obj)->tp_name);
|
||||
goto error;
|
||||
}
|
||||
if (i > 0)
|
||||
|
@ -2725,7 +2725,7 @@ static PyObject *
|
|||
bytes_reduce(PyBytesObject *self)
|
||||
{
|
||||
return Py_BuildValue("(O(s#s))",
|
||||
self->ob_type,
|
||||
Py_Type(self),
|
||||
self->ob_bytes == NULL ? "" : self->ob_bytes,
|
||||
self->ob_size,
|
||||
"latin-1");
|
||||
|
@ -2799,8 +2799,7 @@ PyDoc_STRVAR(bytes_doc,
|
|||
If an argument is given it must be an iterable yielding ints in range(256).");
|
||||
|
||||
PyTypeObject PyBytes_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"bytes",
|
||||
sizeof(PyBytesObject),
|
||||
0,
|
||||
|
|
|
@ -87,8 +87,7 @@ static PyGetSetDef cell_getsetlist[] = {
|
|||
};
|
||||
|
||||
PyTypeObject PyCell_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"cell",
|
||||
sizeof(PyCellObject),
|
||||
0,
|
||||
|
|
|
@ -426,8 +426,7 @@ method_descr_get(PyObject *meth, PyObject *obj, PyObject *cls)
|
|||
}
|
||||
|
||||
PyTypeObject PyMethod_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0,
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"method",
|
||||
sizeof(PyMethodObject),
|
||||
0,
|
||||
|
|
|
@ -135,8 +135,7 @@ extension modules, so that extension modules can use the Python import\n\
|
|||
mechanism to link to one another.");
|
||||
|
||||
PyTypeObject PyCObject_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
0, /*ob_size*/
|
||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"PyCObject", /*tp_name*/
|
||||
sizeof(PyCObject), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue