Skip to content

Commit 61ecb79

Browse files
author
martin.v.loewis
committed
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT. git-svn-id: http://svn.python.org/projects/python/trunk@56476 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 5192ef8 commit 61ecb79

File tree

129 files changed

+1090
-1250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1090
-1250
lines changed

Include/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
10641064
*/
10651065

10661066
#define PySequence_ITEM(o, i)\
1067-
( o->ob_type->tp_as_sequence->sq_item(o, i) )
1067+
( Py_Type(o)->tp_as_sequence->sq_item(o, i) )
10681068
/* Assume tp_as_sequence and sq_item exist and that i does not
10691069
need to be corrected for a negative index
10701070
*/

Include/boolobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ typedef PyIntObject PyBoolObject;
1111

1212
PyAPI_DATA(PyTypeObject) PyBool_Type;
1313

14-
#define PyBool_Check(x) ((x)->ob_type == &PyBool_Type)
14+
#define PyBool_Check(x) (Py_Type(x) == &PyBool_Type)
1515

1616
/* Py_False and Py_True are the only two bools in existence.
1717
Don't forget to apply Py_INCREF() when returning either!!! */

Include/bufferobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C" {
1212

1313
PyAPI_DATA(PyTypeObject) PyBuffer_Type;
1414

15-
#define PyBuffer_Check(op) ((op)->ob_type == &PyBuffer_Type)
15+
#define PyBuffer_Check(op) (Py_Type(op) == &PyBuffer_Type)
1616

1717
#define Py_END_OF_BUFFER (-1)
1818

Include/cStringIO.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ static struct PycStringIO_CAPI {
6060

6161
/* These can be used to test if you have one */
6262
#define PycStringIO_InputCheck(O) \
63-
((O)->ob_type==PycStringIO->InputType)
63+
(Py_Type(O)==PycStringIO->InputType)
6464
#define PycStringIO_OutputCheck(O) \
65-
((O)->ob_type==PycStringIO->OutputType)
65+
(Py_Type(O)==PycStringIO->OutputType)
6666

6767
#ifdef __cplusplus
6868
}

Include/cellobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct {
1313

1414
PyAPI_DATA(PyTypeObject) PyCell_Type;
1515

16-
#define PyCell_Check(op) ((op)->ob_type == &PyCell_Type)
16+
#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type)
1717

1818
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
1919
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);

Include/cobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616

1717
PyAPI_DATA(PyTypeObject) PyCObject_Type;
1818

19-
#define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type)
19+
#define PyCObject_Check(op) (Py_Type(op) == &PyCObject_Type)
2020

2121
/* Create a PyCObject from a pointer to a C object and an optional
2222
destructor function. If the second argument is non-null, then it

Include/code.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct {
6060

6161
PyAPI_DATA(PyTypeObject) PyCode_Type;
6262

63-
#define PyCode_Check(op) ((op)->ob_type == &PyCode_Type)
63+
#define PyCode_Check(op) (Py_Type(op) == &PyCode_Type)
6464
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
6565

6666
/* Public interface */
@@ -72,7 +72,7 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
7272

7373
/* for internal use only */
7474
#define _PyCode_GETCODEPTR(co, pp) \
75-
((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
75+
((*Py_Type((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \
7676
((co)->co_code, 0, (void **)(pp)))
7777

7878
typedef struct _addr_pair {

Include/complexobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct {
4343
PyAPI_DATA(PyTypeObject) PyComplex_Type;
4444

4545
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
46-
#define PyComplex_CheckExact(op) ((op)->ob_type == &PyComplex_Type)
46+
#define PyComplex_CheckExact(op) (Py_Type(op) == &PyComplex_Type)
4747

4848
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
4949
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);

Include/datetime.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,19 @@ typedef struct {
166166

167167
/* Macros for type checking when building the Python core. */
168168
#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType)
169-
#define PyDate_CheckExact(op) ((op)->ob_type == &PyDateTime_DateType)
169+
#define PyDate_CheckExact(op) (Py_Type(op) == &PyDateTime_DateType)
170170

171171
#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType)
172-
#define PyDateTime_CheckExact(op) ((op)->ob_type == &PyDateTime_DateTimeType)
172+
#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType)
173173

174174
#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType)
175-
#define PyTime_CheckExact(op) ((op)->ob_type == &PyDateTime_TimeType)
175+
#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType)
176176

177177
#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType)
178-
#define PyDelta_CheckExact(op) ((op)->ob_type == &PyDateTime_DeltaType)
178+
#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType)
179179

180180
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType)
181-
#define PyTZInfo_CheckExact(op) ((op)->ob_type == &PyDateTime_TZInfoType)
181+
#define PyTZInfo_CheckExact(op) (Py_Type(op) == &PyDateTime_TZInfoType)
182182

183183
#else
184184

@@ -198,19 +198,19 @@ static PyDateTime_CAPI *PyDateTimeAPI;
198198

199199
/* Macros for type checking when not building the Python core. */
200200
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
201-
#define PyDate_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DateType)
201+
#define PyDate_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateType)
202202

203203
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
204-
#define PyDateTime_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DateTimeType)
204+
#define PyDateTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateTimeType)
205205

206206
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
207-
#define PyTime_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->TimeType)
207+
#define PyTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TimeType)
208208

209209
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
210-
#define PyDelta_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->DeltaType)
210+
#define PyDelta_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DeltaType)
211211

212212
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
213-
#define PyTZInfo_CheckExact(op) ((op)->ob_type == PyDateTimeAPI->TZInfoType)
213+
#define PyTZInfo_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TZInfoType)
214214

215215
/* Macros for accessing constructors in a simplified fashion. */
216216
#define PyDate_FromDate(year, month, day) \

Include/descrobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
7777
struct PyGetSetDef *);
7878
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
7979
struct wrapperbase *, void *);
80-
#define PyDescr_IsData(d) ((d)->ob_type->tp_descr_set != NULL)
80+
#define PyDescr_IsData(d) (Py_Type(d)->tp_descr_set != NULL)
8181

8282
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
8383
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);

0 commit comments

Comments
 (0)