Skip to content

Commit 2bc158f

Browse files
Rémi Lapeyremiss-islington
authored andcommitted
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.
1 parent c0a1a07 commit 2bc158f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Modules/_csv.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static PyTypeObject Reader_Type;
111111
typedef struct {
112112
PyObject_HEAD
113113

114-
PyObject *writeline; /* write output lines to this file */
114+
PyObject *write; /* write output lines to this file */
115115

116116
DialectObj *dialect; /* parsing dialect */
117117

@@ -1231,14 +1231,16 @@ csv_writerow(WriterObj *self, PyObject *seq)
12311231

12321232
/* Add line terminator.
12331233
*/
1234-
if (!join_append_lineterminator(self))
1234+
if (!join_append_lineterminator(self)) {
12351235
return NULL;
1236+
}
12361237

12371238
line = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND,
12381239
(void *) self->rec, self->rec_len);
1239-
if (line == NULL)
1240+
if (line == NULL) {
12401241
return NULL;
1241-
result = PyObject_CallFunctionObjArgs(self->writeline, line, NULL);
1242+
}
1243+
result = PyObject_CallFunctionObjArgs(self->write, line, NULL);
12421244
Py_DECREF(line);
12431245
return result;
12441246
}
@@ -1294,7 +1296,7 @@ Writer_dealloc(WriterObj *self)
12941296
{
12951297
PyObject_GC_UnTrack(self);
12961298
Py_XDECREF(self->dialect);
1297-
Py_XDECREF(self->writeline);
1299+
Py_XDECREF(self->write);
12981300
if (self->rec != NULL)
12991301
PyMem_Free(self->rec);
13001302
PyObject_GC_Del(self);
@@ -1304,15 +1306,15 @@ static int
13041306
Writer_traverse(WriterObj *self, visitproc visit, void *arg)
13051307
{
13061308
Py_VISIT(self->dialect);
1307-
Py_VISIT(self->writeline);
1309+
Py_VISIT(self->write);
13081310
return 0;
13091311
}
13101312

13111313
static int
13121314
Writer_clear(WriterObj *self)
13131315
{
13141316
Py_CLEAR(self->dialect);
1315-
Py_CLEAR(self->writeline);
1317+
Py_CLEAR(self->write);
13161318
return 0;
13171319
}
13181320

@@ -1369,7 +1371,7 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
13691371
return NULL;
13701372

13711373
self->dialect = NULL;
1372-
self->writeline = NULL;
1374+
self->write = NULL;
13731375

13741376
self->rec = NULL;
13751377
self->rec_size = 0;
@@ -1380,8 +1382,8 @@ csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args)
13801382
Py_DECREF(self);
13811383
return NULL;
13821384
}
1383-
self->writeline = _PyObject_GetAttrId(output_file, &PyId_write);
1384-
if (self->writeline == NULL || !PyCallable_Check(self->writeline)) {
1385+
self->write = _PyObject_GetAttrId(output_file, &PyId_write);
1386+
if (self->write == NULL || !PyCallable_Check(self->write)) {
13851387
PyErr_SetString(PyExc_TypeError,
13861388
"argument 1 must have a \"write\" method");
13871389
Py_DECREF(self);

0 commit comments

Comments
 (0)