Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 884e051..9271413 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -276,9 +276,8 @@
return -1;
}
else {
- Py_XDECREF(*target);
Py_INCREF(src);
- *target = src;
+ Py_SETREF(*target, src);
}
}
return 0;
@@ -770,8 +769,7 @@
static int
parse_reset(ReaderObj *self)
{
- Py_XDECREF(self->fields);
- self->fields = PyList_New(0);
+ Py_SETREF(self->fields, PyList_New(0));
if (self->fields == NULL)
return -1;
self->field_len = 0;