summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.c
diff options
context:
space:
mode:
authorRĂ©mi Lapeyre <remi.lapeyre@henki.fr>2019-05-14 13:45:14 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-14 13:45:14 (GMT)
commit2bc158fefe89db8dfdd6d03ae6b3f2caa2f0cd6c (patch)
treecb62f2c4f5816074cfd9de798f74c305cfefdafe /Modules/_csv.c
parentc0a1a07c7e9814cad79cce3580c16284b2df7f52 (diff)
downloadcpython-2bc158fefe89db8dfdd6d03ae6b3f2caa2f0cd6c.zip
cpython-2bc158fefe89db8dfdd6d03ae6b3f2caa2f0cd6c.tar.gz
cpython-2bc158fefe89db8dfdd6d03ae6b3f2caa2f0cd6c.tar.bz2
Change WriterObj.writeline to WriterObj.write (GH-12344)
This cleans the csv module a bit, I don't think it requires a bpo issue or a news entry.
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r--Modules/_csv.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index d86f63e..e31b158 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -111,7 +111,7 @@ static PyTypeObject Reader_Type;
typedef struct {
PyObject_HEAD
- PyObject *writeline; /* write output lines to this file */
+ PyObject *write; /* write output lines to this file */
DialectObj *dialect; /* parsing dialect */
@@ -1231,14 +1231,16 @@ csv_writerow(WriterObj *self, PyObject *seq)
/* Add line terminator.
*/
- if (!join_append_lineterminator(self))
+ if (!join_append_lineterminator(self)) {
return NULL;
+ }
line = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND,
(void *) self->rec, self->rec_len);
- if (line == NULL)
+ if (line == NULL) {
return NULL;
- result = PyObject_CallFunctionObjArgs(self->writeline, line, NULL);
+ }
+ result = PyObject_CallFunctionObjArgs(self->write, line, NULL);
Py_DECREF(line);
return result;
}
@@ -1294,7 +1296,7 @@ Writer_dealloc(WriterObj *self)
{
PyObject_GC_UnTrack(self);
Py_XDECREF(self->dialect);
- Py_XDECREF(self->writeline);
+ Py_XDECREF(self->write);
if (self->rec != NULL)
PyMem_Free(self->rec);
PyObject_GC_Del(self);
@@ -1304,7 +1306,7 @@ static int
Writer_traverse(WriterObj *self, visitproc visit, void *arg)
{
Py_VISIT(self->dialect);
- Py_VISIT(self->writeline);
+ Py_VISIT(self->write);
return 0;
}
@@ -1312,7 +1314,7 @@ static int
Writer_clear(WriterObj *self)
{
Py_CLEAR(self->dialect);
- Py_CLEAR(self->writeline);
+ Py_CLEAR(self->write);
return 0;
}
@@ -1369,7 +1371,7 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
return NULL;
self->dialect = NULL;
- self->writeline = NULL;
+ self->write = NULL;
self->rec = NULL;
self->rec_size = 0;
@@ -1380,8 +1382,8 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
Py_DECREF(self);
return NULL;
}
- self->writeline = _PyObject_GetAttrId(output_file, &PyId_write);
- if (self->writeline == NULL || !PyCallable_Check(self->writeline)) {
+ self->write = _PyObject_GetAttrId(output_file, &PyId_write);
+ if (self->write == NULL || !PyCallable_Check(self->write)) {
PyErr_SetString(PyExc_TypeError,
"argument 1 must have a \"write\" method");
Py_DECREF(self);