diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-07-21 06:55:02 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-07-21 06:55:02 (GMT) |
commit | 6819210b9e4e5719a6f7f9c1725f8fa70a8936f6 (patch) | |
tree | 456e2e6b3d9d71e966f3b0e419ecfe44ce3c1fdd /Modules/bz2module.c | |
parent | b1994b4a5d0139a010eb0af1d6615a3df92fe786 (diff) | |
download | cpython-6819210b9e4e5719a6f7f9c1725f8fa70a8936f6.zip cpython-6819210b9e4e5719a6f7f9c1725f8fa70a8936f6.tar.gz cpython-6819210b9e4e5719a6f7f9c1725f8fa70a8936f6.tar.bz2 |
PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
Diffstat (limited to 'Modules/bz2module.c')
-rw-r--r-- | Modules/bz2module.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Modules/bz2module.c b/Modules/bz2module.c index 9d92cf6..053461f 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -41,7 +41,7 @@ typedef fpos_t Py_off_t; #define MODE_READ_EOF 2 #define MODE_WRITE 3 -#define BZ2FileObject_Check(v) ((v)->ob_type == &BZ2File_Type) +#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type) #ifdef BZ_CONFIG_ERROR @@ -1418,7 +1418,7 @@ BZ2File_dealloc(BZ2FileObject *self) } Util_DropReadAhead(self); Py_XDECREF(self->file); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } /* This is a hacked version of Python's fileobject.c:file_getiter(). */ @@ -1480,8 +1480,7 @@ newlines are available only when reading.\n\ ; static PyTypeObject BZ2File_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "bz2.BZ2File", /*tp_name*/ sizeof(BZ2FileObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1735,7 +1734,7 @@ BZ2Comp_dealloc(BZ2CompObject *self) PyThread_free_lock(self->lock); #endif BZ2_bzCompressEnd(&self->bzs); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } @@ -1752,8 +1751,7 @@ must be a number between 1 and 9.\n\ "); static PyTypeObject BZ2Comp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "bz2.BZ2Compressor", /*tp_name*/ sizeof(BZ2CompObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -1958,7 +1956,7 @@ BZ2Decomp_dealloc(BZ2DecompObject *self) #endif Py_XDECREF(self->unused_data); BZ2_bzDecompressEnd(&self->bzs); - self->ob_type->tp_free((PyObject *)self); + Py_Type(self)->tp_free((PyObject *)self); } @@ -1974,8 +1972,7 @@ decompress() function instead.\n\ "); static PyTypeObject BZ2Decomp_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ + PyVarObject_HEAD_INIT(NULL, 0) "bz2.BZ2Decompressor", /*tp_name*/ sizeof(BZ2DecompObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ @@ -2209,9 +2206,9 @@ initbz2(void) { PyObject *m; - BZ2File_Type.ob_type = &PyType_Type; - BZ2Comp_Type.ob_type = &PyType_Type; - BZ2Decomp_Type.ob_type = &PyType_Type; + Py_Type(&BZ2File_Type) = &PyType_Type; + Py_Type(&BZ2Comp_Type) = &PyType_Type; + Py_Type(&BZ2Decomp_Type) = &PyType_Type; m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); if (m == NULL) |