Py_CLEAR(res);
goto end;
}
- Py_CLEAR(res);
- res = _PyBytes_Join(_PyIO_empty_bytes, chunks);
+ Py_SETREF(res, _PyBytes_Join(_PyIO_empty_bytes, chunks));
end:
LEAVE_BUFFERED(self)
if (_PyIOBase_check_readable(raw, Py_True) == NULL)
return -1;
- Py_CLEAR(self->raw);
Py_INCREF(raw);
- self->raw = raw;
+ Py_SETREF(self->raw, raw);
self->buffer_size = buffer_size;
self->readable = 1;
self->writable = 0;
if (_PyIOBase_check_writable(raw, Py_True) == NULL)
return -1;
- Py_CLEAR(self->raw);
Py_INCREF(raw);
- self->raw = raw;
+ Py_SETREF(self->raw, raw);
self->readable = 0;
self->writable = 1;
if (_PyIOBase_check_writable(raw, Py_True) == NULL)
return -1;
- Py_CLEAR(self->raw);
Py_INCREF(raw);
- self->raw = raw;
+ Py_SETREF(self->raw, raw);
self->buffer_size = buffer_size;
self->readable = 1;
self->writable = 1;
"Oi", self->decoder, (int)self->readtranslate);
if (incrementalDecoder == NULL)
goto error;
- Py_CLEAR(self->decoder);
- self->decoder = incrementalDecoder;
+ Py_SETREF(self->decoder, incrementalDecoder);
}
}
static void
textiowrapper_set_decoded_chars(textio *self, PyObject *chars)
{
- Py_CLEAR(self->decoded_chars);
- self->decoded_chars = chars;
+ Py_SETREF(self->decoded_chars, chars);
self->decoded_chars_used = 0;
}
goto fail;
}
Py_DECREF(dec_buffer);
- Py_CLEAR(self->snapshot);
- self->snapshot = Py_BuildValue("NN", dec_flags, next_input);
+ Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input));
}
Py_DECREF(input_chunk);
if (chunks != NULL) {
if (result != NULL && PyList_Append(chunks, result) < 0)
goto fail;
- Py_CLEAR(result);
- result = PyUnicode_Join(_PyIO_empty_str, chunks);
+ Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks));
if (result == NULL)
goto fail;
Py_CLEAR(chunks);
if (chunks != NULL) {
if (line != NULL && PyList_Append(chunks, line) < 0)
goto error;
- Py_CLEAR(line);
- line = PyUnicode_Join(_PyIO_empty_str, chunks);
+ Py_SETREF(line, PyUnicode_Join(_PyIO_empty_str, chunks));
if (line == NULL)
goto error;
Py_DECREF(chunks);
Py_SETREF(self->args, args);
if (PyTuple_GET_SIZE(self->args) == 1) {
- Py_CLEAR(self->message);
- self->message = PyTuple_GET_ITEM(self->args, 0);
- Py_INCREF(self->message);
+ Py_INCREF(PyTuple_GET_ITEM(self->args, 0));
+ Py_SETREF(self->message, PyTuple_GET_ITEM(self->args, 0));
}
return 0;
}
PyErr_SetString(PyExc_TypeError, "__dict__ must be a dictionary");
return -1;
}
- Py_CLEAR(self->dict);
Py_INCREF(val);
- self->dict = val;
+ Py_SETREF(self->dict, val);
return 0;
}
seq = PySequence_Tuple(val);
if (!seq)
return -1;
- Py_CLEAR(self->args);
- self->args = seq;
+ Py_SETREF(self->args, seq);
return 0;
}
&myerrno, &strerror, &filename)) {
return -1;
}
- Py_CLEAR(self->myerrno); /* replacing */
- self->myerrno = myerrno;
- Py_INCREF(self->myerrno);
+ Py_INCREF(myerrno);
+ Py_SETREF(self->myerrno, myerrno);
- Py_CLEAR(self->strerror); /* replacing */
- self->strerror = strerror;
- Py_INCREF(self->strerror);
+ Py_INCREF(strerror);
+ Py_SETREF(self->strerror, strerror);
/* self->filename will remain Py_None otherwise */
if (filename != NULL) {
- Py_CLEAR(self->filename); /* replacing */
- self->filename = filename;
- Py_INCREF(self->filename);
+ Py_INCREF(filename);
+ Py_SETREF(self->filename, filename);
subslice = PyTuple_GetSlice(args, 0, 2);
if (!subslice)
return -1;
posix_errno = winerror_to_errno(errcode);
- Py_CLEAR(self->winerror);
- self->winerror = self->myerrno;
+ Py_SETREF(self->winerror, self->myerrno);
o_errcode = PyInt_FromLong(posix_errno);
if (!o_errcode)
return -1;
if (lenargs >= 1) {
- Py_CLEAR(self->msg);
- self->msg = PyTuple_GET_ITEM(args, 0);
- Py_INCREF(self->msg);
+ Py_INCREF(PyTuple_GET_ITEM(args, 0));
+ Py_SETREF(self->msg, PyTuple_GET_ITEM(args, 0));
}
if (lenargs == 2) {
info = PyTuple_GET_ITEM(args, 1);
return -1;
}
- Py_CLEAR(self->filename);
- self->filename = PyTuple_GET_ITEM(info, 0);
- Py_INCREF(self->filename);
+ Py_INCREF(PyTuple_GET_ITEM(info, 0));
+ Py_SETREF(self->filename, PyTuple_GET_ITEM(info, 0));
- Py_CLEAR(self->lineno);
- self->lineno = PyTuple_GET_ITEM(info, 1);
- Py_INCREF(self->lineno);
+ Py_INCREF(PyTuple_GET_ITEM(info, 1));
+ Py_SETREF(self->lineno, PyTuple_GET_ITEM(info, 1));
- Py_CLEAR(self->offset);
- self->offset = PyTuple_GET_ITEM(info, 2);
- Py_INCREF(self->offset);
+ Py_INCREF(PyTuple_GET_ITEM(info, 2));
+ Py_SETREF(self->offset, PyTuple_GET_ITEM(info, 2));
- Py_CLEAR(self->text);
- self->text = PyTuple_GET_ITEM(info, 3);
- Py_INCREF(self->text);
+ Py_INCREF(PyTuple_GET_ITEM(info, 3));
+ Py_SETREF(self->text, PyTuple_GET_ITEM(info, 3));
Py_DECREF(info);
}
PyObject *obj = PyString_FromString(value);
if (!obj)
return -1;
- Py_CLEAR(*attr);
- *attr = obj;
+ Py_SETREF(*attr, obj);
return 0;
}