Mercurial > cpython-lru_cache-weakref
annotate Modules/xreadlinesmodule.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 91dd223829c6 |
| children | ed1ba37a46b7 |
| rev | line source |
|---|---|
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 #include "Python.h" |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 static char xreadlines_doc [] = |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 "xreadlines(f)\n\ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 \n\ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 Return an xreadlines object for the file f."; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 typedef struct { |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 PyObject_HEAD |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 PyObject *file; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 PyObject *lines; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 int lineslen; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 int lineno; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 int abslineno; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 } PyXReadlinesObject; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 staticforward PyTypeObject XReadlinesObject_Type; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 static void |
|
15819
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
20 xreadlines_dealloc(PyXReadlinesObject *op) |
|
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
21 { |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 Py_XDECREF(op->file); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 Py_XDECREF(op->lines); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 PyObject_DEL(op); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 } |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 /* A larger chunk size doesn't seem to make a difference */ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #define CHUNKSIZE 8192 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 static PyXReadlinesObject * |
|
15819
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
31 newreadlinesobject(PyObject *file) |
|
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
32 { |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 PyXReadlinesObject *op; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 op = PyObject_NEW(PyXReadlinesObject, &XReadlinesObject_Type); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 if (op == NULL) |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 return NULL; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 Py_XINCREF(file); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 op->file = file; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 op->lines = NULL; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 op->abslineno = op->lineno = op->lineslen = 0; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 return op; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 } |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 static PyObject * |
|
15819
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
45 xreadlines(PyObject *self, PyObject *args) |
|
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
46 { |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 PyObject *file; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 PyXReadlinesObject *ret; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 if (!PyArg_ParseTuple(args, "O:xreadlines", &file)) |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 return NULL; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 ret = newreadlinesobject(file); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 return (PyObject*)ret; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 } |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 |
|
15819
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
56 static PyObject * |
|
17909
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
57 xreadlines_common(PyXReadlinesObject *a) |
|
15819
79770ca15c5a
Conform the new module to /the/ C style.
Thomas Wouters <thomas@python.org>
parents:
15791
diff
changeset
|
58 { |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 if (a->lineno >= a->lineslen) { |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 Py_XDECREF(a->lines); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 a->lines = PyObject_CallMethod(a->file, "readlines", "(i)", |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 CHUNKSIZE); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 if (a->lines == NULL) |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 return NULL; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 a->lineno = 0; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 if ((a->lineslen = PySequence_Size(a->lines)) < 0) |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 return NULL; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 } |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 a->abslineno++; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 return PySequence_GetItem(a->lines, a->lineno++); |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 } |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 |
|
17909
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
73 static PyObject * |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
74 xreadlines_item(PyXReadlinesObject *a, int i) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
75 { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
76 if (i != a->abslineno) { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
77 PyErr_SetString(PyExc_RuntimeError, |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
78 "xreadlines object accessed out of order"); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
79 return NULL; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
80 } |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
81 return xreadlines_common(a); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
82 } |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
83 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
84 static PyObject * |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
85 xreadlines_getiter(PyXReadlinesObject *a) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
86 { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
87 Py_INCREF(a); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
88 return (PyObject *)a; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
89 } |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
90 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
91 static PyObject * |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
92 xreadlines_iternext(PyXReadlinesObject *a) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
93 { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
94 PyObject *res; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
95 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
96 res = xreadlines_common(a); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
97 if (res == NULL && PyErr_ExceptionMatches(PyExc_IndexError)) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
98 PyErr_Clear(); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
99 return res; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
100 } |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
101 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
102 static PyObject * |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
103 xreadlines_next(PyXReadlinesObject *a, PyObject *args) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
104 { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
105 PyObject *res; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
106 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
107 if (!PyArg_ParseTuple(args, "")) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
108 return NULL; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
109 res = xreadlines_common(a); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
110 if (res == NULL && PyErr_ExceptionMatches(PyExc_IndexError)) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
111 PyErr_SetObject(PyExc_StopIteration, Py_None); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
112 return res; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
113 } |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
114 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
115 static char next_doc[] = "x.next() -> the next line or raise StopIteration"; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
116 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
117 static PyMethodDef xreadlines_methods[] = { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
118 {"next", (PyCFunction)xreadlines_next, METH_VARARGS, next_doc}, |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
119 {NULL, NULL} |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
120 }; |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
121 |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
122 static PyObject * |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
123 xreadlines_getattr(PyObject *a, char *name) |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
124 { |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
125 return Py_FindMethod(xreadlines_methods, a, name); |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
126 } |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
127 |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 static PySequenceMethods xreadlines_as_sequence = { |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 0, /*sq_length*/ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 0, /*sq_concat*/ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 0, /*sq_repeat*/ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 (intargfunc)xreadlines_item, /*sq_item*/ |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 }; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 static PyTypeObject XReadlinesObject_Type = { |
|
16008
4c856a180458
SF Patch #103185, by jlt63: Some more standard modules cleanup for Cygwin
Guido van Rossum <guido@python.org>
parents:
15819
diff
changeset
|
136 PyObject_HEAD_INIT(NULL) |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 0, |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
19578
diff
changeset
|
138 "xreadlines.xreadlines", |
|
19578
f6f93419bfb6
Remove bogus PyGC_HEAD_SIZE.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
18754
diff
changeset
|
139 sizeof(PyXReadlinesObject), |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 0, |
|
17909
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
141 (destructor)xreadlines_dealloc, /* tp_dealloc */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
142 0, /* tp_print */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
143 xreadlines_getattr, /* tp_getattr */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
144 0, /* tp_setattr */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
145 0, /* tp_compare */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
146 0, /* tp_repr */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
147 0, /* tp_as_number */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
148 &xreadlines_as_sequence, /* tp_as_sequence */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
149 0, /* tp_as_mapping */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
150 0, /* tp_hash */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
151 0, /* tp_call */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
152 0, /* tp_str */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
153 0, /* tp_getattro */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
154 0, /* tp_setattro */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
155 0, /* tp_as_buffer */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
156 Py_TPFLAGS_DEFAULT, /* tp_flags */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
157 0, /* tp_doc */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
158 0, /* tp_traverse */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
159 0, /* tp_clear */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
160 0, /* tp_richcompare */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
161 0, /* tp_weaklistoffset */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
162 (getiterfunc)xreadlines_getiter, /* tp_iter */ |
|
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
163 (iternextfunc)xreadlines_iternext, /* tp_iternext */ |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 }; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 |
|
17909
77871c499215
Iterator support: made the xreadlines object its own iterator. This
Guido van Rossum <guido@python.org>
parents:
17214
diff
changeset
|
166 static PyMethodDef xreadlines_functions[] = { |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 {"xreadlines", xreadlines, METH_VARARGS, xreadlines_doc}, |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 {NULL, NULL} |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 }; |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 |
|
15791
4854ee585e0d
Assorted xreadlines problems:
Tim Peters <tim.peters@gmail.com>
parents:
15778
diff
changeset
|
171 DL_EXPORT(void) |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 initxreadlines(void) |
|
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 { |
|
16008
4c856a180458
SF Patch #103185, by jlt63: Some more standard modules cleanup for Cygwin
Guido van Rossum <guido@python.org>
parents:
15819
diff
changeset
|
174 XReadlinesObject_Type.ob_type = &PyType_Type; |
|
18754
3cd03a64c338
Make more warnings go away on the SGI compiler.
Fred Drake <fdrake@acm.org>
parents:
17909
diff
changeset
|
175 Py_InitModule("xreadlines", xreadlines_functions); |
|
15778
b5a37bf9d12d
Jeff Epler's xreadlines module, with slight reformatting and some
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 } |
