[Python-checkins] python/dist/src/Modules bz2module.c,1.14,1.15
niemeyer@users.sourceforge.net
niemeyer@users.sourceforge.net
2003年2月11日 10:46:22 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv21903/Modules
Modified Files:
bz2module.c
Log Message:
Unparenting BZ2File, as discussed in SF patch #661796.
* Modules/bz2module.c
(BZ2FileObject): Now the structure includes a pointer to a file object,
instead of "inheriting" one. Also, some members were copied from the
PyFileObject structure to avoid dealing with the internals of that
structure from outside fileobject.c.
(Util_GetLine,Util_DropReadAhead,Util_ReadAhead,Util_ReadAheadGetLineSkip,
BZ2File_write,BZ2File_writelines,BZ2File_init,BZ2File_dealloc,
BZ2Comp_dealloc,BZ2Decomp_dealloc):
These functions were adapted to the change above.
(BZ2File_seek,BZ2File_close): Use PyObject_CallMethod instead of
getting the function attribute locally.
(BZ2File_notsup): Removed, since it's not necessary anymore to overload
truncate(), and readinto() with dummy functions.
(BZ2File_methods): Added xreadlines() as an alias to BZ2File_getiter,
and removed truncate() and readinto().
(BZ2File_get_newlines,BZ2File_get_closed,BZ2File_get_mode,BZ2File_get_name,
BZ2File_getset):
Implemented getters for "newlines", "mode", and "name".
(BZ2File_members): Implemented "softspace" member.
(BZ2File_init): Reworked to create a file instance instead of initializing
itself as a file subclass. Also, pass "name" object untouched to the
file constructor, and use PyObject_CallFunction instead of building the
argument tuple locally.
(BZ2File_Type): Set tp_new to PyType_GenericNew, tp_members to
BZ2File_members, and tp_getset to BZ2File_getset.
(initbz2): Do not set BZ2File_Type.tp_base nor BZ2File_Type.tp_new.
* Doc/lib/libbz2.tex
Do not mention that BZ2File inherits from the file type.
Index: bz2module.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/bz2module.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** bz2module.c 6 Jan 2003 12:41:25 -0000 1.14
--- bz2module.c 11 Feb 2003 18:46:19 -0000 1.15
***************
*** 63,67 ****
typedef struct {
! PyFileObject file;
BZFILE *fp;
int mode;
--- 63,81 ----
typedef struct {
! PyObject_HEAD
! PyObject *file;
!
! char* f_buf; /* Allocated readahead buffer */
! char* f_bufend; /* Points after last occupied position */
! char* f_bufptr; /* Current buffer position */
!
! int f_softspace; /* Flag used by 'print' command */
!
! #ifdef WITH_UNIVERSAL_NEWLINES
! int f_univ_newline; /* Handle any newline convention */
! int f_newlinetypes; /* Types of newlines seen */
! int f_skipnextlf; /* Skip next \n */
! #endif
!
BZFILE *fp;
int mode;
***************
*** 180,184 ****
/* This is a hacked version of Python's fileobject.c:get_line(). */
static PyObject *
! Util_GetLine(BZ2FileObject *self, int n)
{
char c;
--- 194,198 ----
/* This is a hacked version of Python's fileobject.c:get_line(). */
static PyObject *
! Util_GetLine(BZ2FileObject *f, int n)
{
char c;
***************
*** 190,196 ****
int bzerror;
#ifdef WITH_UNIVERSAL_NEWLINES
! int newlinetypes = ((PyFileObject*)self)->f_newlinetypes;
! int skipnextlf = ((PyFileObject*)self)->f_skipnextlf;
! int univ_newline = ((PyFileObject*)self)->f_univ_newline;
#endif
--- 204,210 ----
int bzerror;
#ifdef WITH_UNIVERSAL_NEWLINES
! int newlinetypes = f->f_newlinetypes;
! int skipnextlf = f->f_skipnextlf;
! int univ_newline = f->f_univ_newline;
#endif
***************
*** 208,213 ****
if (univ_newline) {
while (1) {
! BZ2_bzRead(&bzerror, self->fp, &c, 1);
! self->pos++;
if (bzerror != BZ_OK || buf == end)
break;
--- 222,227 ----
if (univ_newline) {
while (1) {
! BZ2_bzRead(&bzerror, f->fp, &c, 1);
! f->pos++;
if (bzerror != BZ_OK || buf == end)
break;
***************
*** 220,224 ****
*/
newlinetypes |= NEWLINE_CRLF;
! BZ2_bzRead(&bzerror, self->fp,
&c, 1);
if (bzerror != BZ_OK)
--- 234,238 ----
*/
newlinetypes |= NEWLINE_CRLF;
! BZ2_bzRead(&bzerror, f->fp,
&c, 1);
if (bzerror != BZ_OK)
***************
*** 241,256 ****
#endif
do {
! BZ2_bzRead(&bzerror, self->fp, &c, 1);
! self->pos++;
*buf++ = c;
} while (bzerror == BZ_OK && c != '\n' && buf != end);
Py_END_ALLOW_THREADS
#ifdef WITH_UNIVERSAL_NEWLINES
! ((PyFileObject*)self)->f_newlinetypes = newlinetypes;
! ((PyFileObject*)self)->f_skipnextlf = skipnextlf;
#endif
if (bzerror == BZ_STREAM_END) {
! self->size = self->pos;
! self->mode = MODE_READ_EOF;
break;
} else if (bzerror != BZ_OK) {
--- 255,270 ----
#endif
do {
! BZ2_bzRead(&bzerror, f->fp, &c, 1);
! f->pos++;
*buf++ = c;
} while (bzerror == BZ_OK && c != '\n' && buf != end);
Py_END_ALLOW_THREADS
#ifdef WITH_UNIVERSAL_NEWLINES
! f->f_newlinetypes = newlinetypes;
! f->f_skipnextlf = skipnextlf;
#endif
if (bzerror == BZ_STREAM_END) {
! f->size = f->pos;
! f->mode = MODE_READ_EOF;
break;
} else if (bzerror != BZ_OK) {
***************
*** 292,299 ****
size_t
Util_UnivNewlineRead(int *bzerror, BZFILE *stream,
! char* buf, size_t n, BZ2FileObject *fobj)
{
char *dst = buf;
- PyFileObject *f = (PyFileObject *)fobj;
int newlinetypes, skipnextlf;
--- 306,312 ----
size_t
Util_UnivNewlineRead(int *bzerror, BZFILE *stream,
! char* buf, size_t n, BZ2FileObject *f)
{
char *dst = buf;
int newlinetypes, skipnextlf;
***************
*** 360,366 ****
/* This is a hacked version of Python's fileobject.c:drop_readahead(). */
static void
! Util_DropReadAhead(BZ2FileObject *self)
{
- PyFileObject *f = (PyFileObject*)self;
if (f->f_buf != NULL) {
PyMem_Free(f->f_buf);
--- 373,378 ----
/* This is a hacked version of Python's fileobject.c:drop_readahead(). */
static void
! Util_DropReadAhead(BZ2FileObject *f)
{
if (f->f_buf != NULL) {
PyMem_Free(f->f_buf);
***************
*** 371,379 ****
/* This is a hacked version of Python's fileobject.c:readahead(). */
static int
! Util_ReadAhead(BZ2FileObject *self, int bufsize)
{
int chunksize;
int bzerror;
- PyFileObject *f = (PyFileObject*)self;
if (f->f_buf != NULL) {
--- 383,390 ----
/* This is a hacked version of Python's fileobject.c:readahead(). */
static int
! Util_ReadAhead(BZ2FileObject *f, int bufsize)
{
int chunksize;
int bzerror;
if (f->f_buf != NULL) {
***************
*** 381,387 ****
return 0;
else
! Util_DropReadAhead(self);
}
! if (self->mode == MODE_READ_EOF) {
return -1;
}
--- 392,398 ----
return 0;
else
! Util_DropReadAhead(f);
}
! if (f->mode == MODE_READ_EOF) {
return -1;
}
***************
*** 390,403 ****
}
Py_BEGIN_ALLOW_THREADS
! chunksize = Util_UnivNewlineRead(&bzerror, self->fp, f->f_buf,
! bufsize, self);
Py_END_ALLOW_THREADS
! self->pos += chunksize;
if (bzerror == BZ_STREAM_END) {
! self->size = self->pos;
! self->mode = MODE_READ_EOF;
} else if (bzerror != BZ_OK) {
Util_CatchBZ2Error(bzerror);
! Util_DropReadAhead(self);
return -1;
}
--- 401,414 ----
}
Py_BEGIN_ALLOW_THREADS
! chunksize = Util_UnivNewlineRead(&bzerror, f->fp, f->f_buf,
! bufsize, f);
Py_END_ALLOW_THREADS
! f->pos += chunksize;
if (bzerror == BZ_STREAM_END) {
! f->size = f->pos;
! f->mode = MODE_READ_EOF;
} else if (bzerror != BZ_OK) {
Util_CatchBZ2Error(bzerror);
! Util_DropReadAhead(f);
return -1;
}
***************
*** 410,416 ****
* fileobject.c:readahead_get_line_skip(). */
static PyStringObject *
! Util_ReadAheadGetLineSkip(BZ2FileObject *bf, int skip, int bufsize)
{
- PyFileObject *f = (PyFileObject*)bf;
PyStringObject* s;
char *bufptr;
--- 421,426 ----
* fileobject.c:readahead_get_line_skip(). */
static PyStringObject *
! Util_ReadAheadGetLineSkip(BZ2FileObject *f, int skip, int bufsize)
{
PyStringObject* s;
char *bufptr;
***************
*** 419,423 ****
if (f->f_buf == NULL)
! if (Util_ReadAhead(bf, bufsize) < 0)
return NULL;
--- 429,433 ----
if (f->f_buf == NULL)
! if (Util_ReadAhead(f, bufsize) < 0)
return NULL;
***************
*** 437,447 ****
f->f_bufptr = bufptr;
if (bufptr == f->f_bufend)
! Util_DropReadAhead(bf);
} else {
bufptr = f->f_bufptr;
buf = f->f_buf;
f->f_buf = NULL; /* Force new readahead buffer */
! s = Util_ReadAheadGetLineSkip(
! bf, skip+len, bufsize + (bufsize>>2) );
if (s == NULL) {
PyMem_Free(buf);
--- 447,457 ----
f->f_bufptr = bufptr;
if (bufptr == f->f_bufend)
! Util_DropReadAhead(f);
} else {
bufptr = f->f_bufptr;
buf = f->f_buf;
f->f_buf = NULL; /* Force new readahead buffer */
! s = Util_ReadAheadGetLineSkip(f, skip+len,
! bufsize + (bufsize>>2));
if (s == NULL) {
PyMem_Free(buf);
***************
*** 744,747 ****
--- 754,764 ----
}
+ PyDoc_STRVAR(BZ2File_xreadlines__doc__,
+ "xreadlines() -> self\n\
+ \n\
+ For backward compatibility. BZ2File objects now include the performance\n\
+ optimizations previously implemented in the xreadlines module.\n\
+ ");
+
PyDoc_STRVAR(BZ2File_write__doc__,
"write(data) -> None\n\
***************
*** 779,783 ****
}
! PyFile_SoftSpace((PyObject*)self, 0);
Py_BEGIN_ALLOW_THREADS
--- 796,800 ----
}
! self->f_softspace = 0;
Py_BEGIN_ALLOW_THREADS
***************
*** 885,889 ****
}
! PyFile_SoftSpace((PyObject*)self, 0);
/* Since we are releasing the global lock, the
--- 902,906 ----
}
! self->f_softspace = 0;
/* Since we are releasing the global lock, the
***************
*** 944,948 ****
int bzerror;
int rewind = 0;
- PyObject *func;
PyObject *ret = NULL;
--- 961,964 ----
***************
*** 1013,1028 ****
if (rewind) {
BZ2_bzReadClose(&bzerror, self->fp);
- func = Py_FindMethod(PyFile_Type.tp_methods, (PyObject*)self,
- "seek");
if (bzerror != BZ_OK) {
Util_CatchBZ2Error(bzerror);
goto cleanup;
}
! if (!func) {
! PyErr_SetString(PyExc_RuntimeError,
! "can't find file.seek method");
! goto cleanup;
! }
! ret = PyObject_CallFunction(func, "(i)", 0);
if (!ret)
goto cleanup;
--- 1029,1037 ----
if (rewind) {
BZ2_bzReadClose(&bzerror, self->fp);
if (bzerror != BZ_OK) {
Util_CatchBZ2Error(bzerror);
goto cleanup;
}
! ret = PyObject_CallMethod(self->file, "seek", "(i)", 0);
if (!ret)
goto cleanup;
***************
*** 1030,1035 ****
ret = NULL;
self->pos = 0;
! self->fp = BZ2_bzReadOpen(&bzerror,
! PyFile_AsFile((PyObject*)self),
0, 0, NULL, 0);
if (bzerror != BZ_OK) {
--- 1039,1043 ----
ret = NULL;
self->pos = 0;
! self->fp = BZ2_bzReadOpen(&bzerror, PyFile_AsFile(self->file),
0, 0, NULL, 0);
if (bzerror != BZ_OK) {
***************
*** 1102,1116 ****
}
- PyDoc_STRVAR(BZ2File_notsup__doc__,
- "Operation not supported.\n\
- ");
-
- static PyObject *
- BZ2File_notsup(BZ2FileObject *self, PyObject *args)
- {
- PyErr_SetString(PyExc_IOError, "operation not supported");
- return NULL;
- }
-
PyDoc_STRVAR(BZ2File_close__doc__,
"close() -> None or (perhaps) an integer\n\
--- 1110,1113 ----
***************
*** 1124,1128 ****
BZ2File_close(BZ2FileObject *self)
{
- PyObject *file_close;
PyObject *ret = NULL;
int bzerror = BZ_OK;
--- 1121,1124 ----
***************
*** 1140,1173 ****
}
self->mode = MODE_CLOSED;
! file_close = Py_FindMethod(PyFile_Type.tp_methods, (PyObject*)self,
! "close");
! if (!file_close) {
! PyErr_SetString(PyExc_RuntimeError,
! "can't find file.close method");
! goto cleanup;
! }
! ret = PyObject_CallObject(file_close, NULL);
if (bzerror != BZ_OK) {
Util_CatchBZ2Error(bzerror);
Py_XDECREF(ret);
ret = NULL;
- goto cleanup;
}
- cleanup:
RELEASE_LOCK(self);
return ret;
}
static PyMethodDef BZ2File_methods[] = {
{"read", (PyCFunction)BZ2File_read, METH_VARARGS, BZ2File_read__doc__},
{"readline", (PyCFunction)BZ2File_readline, METH_VARARGS, BZ2File_readline__doc__},
{"readlines", (PyCFunction)BZ2File_readlines, METH_VARARGS, BZ2File_readlines__doc__},
{"write", (PyCFunction)BZ2File_write, METH_VARARGS, BZ2File_write__doc__},
{"writelines", (PyCFunction)BZ2File_writelines, METH_O, BZ2File_writelines__doc__},
{"seek", (PyCFunction)BZ2File_seek, METH_VARARGS, BZ2File_seek__doc__},
{"tell", (PyCFunction)BZ2File_tell, METH_NOARGS, BZ2File_tell__doc__},
- {"truncate", (PyCFunction)BZ2File_notsup, METH_VARARGS, BZ2File_notsup__doc__},
- {"readinto", (PyCFunction)BZ2File_notsup, METH_VARARGS, BZ2File_notsup__doc__},
{"close", (PyCFunction)BZ2File_close, METH_NOARGS, BZ2File_close__doc__},
{NULL, NULL} /* sentinel */
--- 1136,1161 ----
}
self->mode = MODE_CLOSED;
! ret = PyObject_CallMethod(self->file, "close", NULL);
if (bzerror != BZ_OK) {
Util_CatchBZ2Error(bzerror);
Py_XDECREF(ret);
ret = NULL;
}
RELEASE_LOCK(self);
return ret;
}
+ static PyObject *BZ2File_getiter(BZ2FileObject *self);
+
static PyMethodDef BZ2File_methods[] = {
{"read", (PyCFunction)BZ2File_read, METH_VARARGS, BZ2File_read__doc__},
{"readline", (PyCFunction)BZ2File_readline, METH_VARARGS, BZ2File_readline__doc__},
{"readlines", (PyCFunction)BZ2File_readlines, METH_VARARGS, BZ2File_readlines__doc__},
+ {"xreadlines", (PyCFunction)BZ2File_getiter, METH_VARARGS, BZ2File_xreadlines__doc__},
{"write", (PyCFunction)BZ2File_write, METH_VARARGS, BZ2File_write__doc__},
{"writelines", (PyCFunction)BZ2File_writelines, METH_O, BZ2File_writelines__doc__},
{"seek", (PyCFunction)BZ2File_seek, METH_VARARGS, BZ2File_seek__doc__},
{"tell", (PyCFunction)BZ2File_tell, METH_NOARGS, BZ2File_tell__doc__},
{"close", (PyCFunction)BZ2File_close, METH_NOARGS, BZ2File_close__doc__},
{NULL, NULL} /* sentinel */
***************
*** 1176,1179 ****
--- 1164,1247 ----
/* ===================================================================== */
+ /* Getters and setters of BZ2File. */
+
+ #ifdef WITH_UNIVERSAL_NEWLINES
+ /* This is a hacked version of Python's fileobject.c:get_newlines(). */
+ static PyObject *
+ BZ2File_get_newlines(BZ2FileObject *self, void *closure)
+ {
+ switch (self->f_newlinetypes) {
+ case NEWLINE_UNKNOWN:
+ Py_INCREF(Py_None);
+ return Py_None;
+ case NEWLINE_CR:
+ return PyString_FromString("\r");
+ case NEWLINE_LF:
+ return PyString_FromString("\n");
+ case NEWLINE_CR|NEWLINE_LF:
+ return Py_BuildValue("(ss)", "\r", "\n");
+ case NEWLINE_CRLF:
+ return PyString_FromString("\r\n");
+ case NEWLINE_CR|NEWLINE_CRLF:
+ return Py_BuildValue("(ss)", "\r", "\r\n");
+ case NEWLINE_LF|NEWLINE_CRLF:
+ return Py_BuildValue("(ss)", "\n", "\r\n");
+ case NEWLINE_CR|NEWLINE_LF|NEWLINE_CRLF:
+ return Py_BuildValue("(sss)", "\r", "\n", "\r\n");
+ default:
+ PyErr_Format(PyExc_SystemError,
+ "Unknown newlines value 0x%x\n",
+ self->f_newlinetypes);
+ return NULL;
+ }
+ }
+ #endif
+
+ static PyObject *
+ BZ2File_get_closed(BZ2FileObject *self, void *closure)
+ {
+ return PyInt_FromLong(self->mode == MODE_CLOSED);
+ }
+
+ static PyObject *
+ BZ2File_get_mode(BZ2FileObject *self, void *closure)
+ {
+ return PyObject_GetAttrString(self->file, "mode");
+ }
+
+ static PyObject *
+ BZ2File_get_name(BZ2FileObject *self, void *closure)
+ {
+ return PyObject_GetAttrString(self->file, "name");
+ }
+
+ static PyGetSetDef BZ2File_getset[] = {
+ {"closed", (getter)BZ2File_get_closed, NULL,
+ "True if the file is closed"},
+ #ifdef WITH_UNIVERSAL_NEWLINES
+ {"newlines", (getter)BZ2File_get_newlines, NULL,
+ "end-of-line convention used in this file"},
+ #endif
+ {"mode", (getter)BZ2File_get_mode, NULL,
+ "file mode ('r', 'w', or 'U')"},
+ {"name", (getter)BZ2File_get_name, NULL,
+ "file name"},
+ {NULL} /* Sentinel */
+ };
+
+
+ /* ===================================================================== */
+ /* Members of BZ2File_Type. */
+
+ #undef OFF
+ #define OFF(x) offsetof(BZ2FileObject, x)
+
+ static PyMemberDef BZ2File_members[] = {
+ {"softspace", T_INT, OFF(f_softspace), 0,
+ "flag indicating that a space needs to be printed; used by print"},
+ {NULL} /* Sentinel */
+ };
+
+ /* ===================================================================== */
/* Slot definitions for BZ2File_Type. */
***************
*** 1181,1188 ****
BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
{
- PyObject *file_args = NULL;
static char *kwlist[] = {"filename", "mode", "buffering",
"compresslevel", 0};
! char *name = NULL;
char *mode = "r";
int buffering = -1;
--- 1249,1255 ----
BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = {"filename", "mode", "buffering",
"compresslevel", 0};
! PyObject *name;
char *mode = "r";
int buffering = -1;
***************
*** 1190,1200 ****
int bzerror;
int mode_char = 0;
- int univ_newline = 0;
self->size = -1;
! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "et|sii:BZ2File",
! kwlist, Py_FileSystemDefaultEncoding,
! &name, &mode, &buffering,
&compresslevel))
return -1;
--- 1257,1265 ----
int bzerror;
int mode_char = 0;
self->size = -1;
! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sii:BZ2File",
! kwlist, &name, &mode, &buffering,
&compresslevel))
return -1;
***************
*** 1220,1224 ****
case 'U':
! univ_newline = 1;
break;
--- 1285,1289 ----
case 'U':
! self->f_univ_newline = 1;
break;
***************
*** 1237,1247 ****
}
! if (mode_char == 'r')
! mode = univ_newline ? "rbU" : "rb";
! else
! mode = univ_newline ? "wbU" : "wb";
! file_args = Py_BuildValue("(ssi)", name, mode, buffering);
! if (!file_args)
return -1;
--- 1302,1310 ----
}
! mode = (mode_char == 'r') ? "rb" : "wb";
! self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)",
! name, mode, buffering);
! if (self->file == NULL)
return -1;
***************
*** 1249,1255 ****
* instead of returning */
- if (PyFile_Type.tp_init((PyObject *)self, file_args, NULL) < 0)
- goto error;
-
#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
--- 1312,1315 ----
***************
*** 1260,1268 ****
if (mode_char == 'r')
self->fp = BZ2_bzReadOpen(&bzerror,
! PyFile_AsFile((PyObject*)self),
0, 0, NULL, 0);
else
self->fp = BZ2_bzWriteOpen(&bzerror,
! PyFile_AsFile((PyObject*)self),
compresslevel, 0, 0);
--- 1320,1328 ----
if (mode_char == 'r')
self->fp = BZ2_bzReadOpen(&bzerror,
! PyFile_AsFile(self->file),
0, 0, NULL, 0);
else
self->fp = BZ2_bzWriteOpen(&bzerror,
! PyFile_AsFile(self->file),
compresslevel, 0, 0);
***************
*** 1274,1288 ****
self->mode = (mode_char == 'r') ? MODE_READ : MODE_WRITE;
- Py_XDECREF(file_args);
- PyMem_Free(name);
return 0;
error:
#ifdef WITH_THREAD
if (self->lock)
PyThread_free_lock(self->lock);
#endif
- Py_XDECREF(file_args);
- PyMem_Free(name);
return -1;
}
--- 1334,1345 ----
self->mode = (mode_char == 'r') ? MODE_READ : MODE_WRITE;
return 0;
error:
+ Py_DECREF(self->file);
#ifdef WITH_THREAD
if (self->lock)
PyThread_free_lock(self->lock);
#endif
return -1;
}
***************
*** 1307,1311 ****
}
Util_DropReadAhead(self);
! ((PyObject*)self)->ob_type->tp_free((PyObject *)self);
}
--- 1364,1369 ----
}
Util_DropReadAhead(self);
! Py_DECREF(self->file);
! self->ob_type->tp_free((PyObject *)self);
}
***************
*** 1400,1405 ****
(iternextfunc)BZ2File_iternext, /*tp_iternext*/
BZ2File_methods, /*tp_methods*/
! 0, /*tp_members*/
! 0, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
--- 1458,1463 ----
(iternextfunc)BZ2File_iternext, /*tp_iternext*/
BZ2File_methods, /*tp_methods*/
! BZ2File_members, /*tp_members*/
! BZ2File_getset, /*tp_getset*/
0, /*tp_base*/
0, /*tp_dict*/
***************
*** 1409,1413 ****
(initproc)BZ2File_init, /*tp_init*/
PyType_GenericAlloc, /*tp_alloc*/
! 0, /*tp_new*/
_PyObject_Del, /*tp_free*/
0, /*tp_is_gc*/
--- 1467,1471 ----
(initproc)BZ2File_init, /*tp_init*/
PyType_GenericAlloc, /*tp_alloc*/
! PyType_GenericNew, /*tp_new*/
_PyObject_Del, /*tp_free*/
0, /*tp_is_gc*/
***************
*** 1619,1623 ****
#endif
BZ2_bzCompressEnd(&self->bzs);
! ((PyObject*)self)->ob_type->tp_free((PyObject *)self);
}
--- 1677,1681 ----
#endif
BZ2_bzCompressEnd(&self->bzs);
! self->ob_type->tp_free((PyObject *)self);
}
***************
*** 1683,1686 ****
--- 1741,1745 ----
/* Members of BZ2Decomp. */
+ #undef OFF
#define OFF(x) offsetof(BZ2DecompObject, x)
***************
*** 1837,1841 ****
Py_XDECREF(self->unused_data);
BZ2_bzDecompressEnd(&self->bzs);
! ((PyObject*)self)->ob_type->tp_free((PyObject *)self);
}
--- 1896,1900 ----
Py_XDECREF(self->unused_data);
BZ2_bzDecompressEnd(&self->bzs);
! self->ob_type->tp_free((PyObject *)self);
}
***************
*** 2088,2094 ****
BZ2File_Type.ob_type = &PyType_Type;
- BZ2File_Type.tp_base = &PyFile_Type;
- BZ2File_Type.tp_new = PyFile_Type.tp_new;
-
BZ2Comp_Type.ob_type = &PyType_Type;
BZ2Decomp_Type.ob_type = &PyType_Type;
--- 2147,2150 ----