Issue #20440: Applied yet one patch for using Py_SETREF.
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
This commit is contained in:
parent
82ea0f9517
commit
8688acaf2e
|
@ -1028,8 +1028,7 @@ found:
|
|||
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)
|
||||
|
@ -1264,9 +1263,8 @@ bufferedreader_init(buffered *self, PyObject *args, PyObject *kwds)
|
|||
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;
|
||||
|
@ -1687,9 +1685,8 @@ bufferedwriter_init(buffered *self, PyObject *args, PyObject *kwds)
|
|||
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;
|
||||
|
||||
|
@ -2344,9 +2341,8 @@ bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds)
|
|||
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;
|
||||
|
|
|
@ -966,8 +966,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds)
|
|||
"Oi", self->decoder, (int)self->readtranslate);
|
||||
if (incrementalDecoder == NULL)
|
||||
goto error;
|
||||
Py_CLEAR(self->decoder);
|
||||
self->decoder = incrementalDecoder;
|
||||
Py_SETREF(self->decoder, incrementalDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1347,8 +1346,7 @@ textiowrapper_write(textio *self, PyObject *args)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -1477,8 +1475,7 @@ textiowrapper_read_chunk(textio *self)
|
|||
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);
|
||||
|
||||
|
@ -1578,8 +1575,7 @@ textiowrapper_read(textio *self, PyObject *args)
|
|||
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);
|
||||
|
@ -1836,8 +1832,7 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit)
|
|||
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);
|
||||
|
|
|
@ -1377,15 +1377,13 @@ s_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
|
||||
if (PyString_Check(o_format)) {
|
||||
Py_INCREF(o_format);
|
||||
Py_CLEAR(soself->s_format);
|
||||
soself->s_format = o_format;
|
||||
Py_SETREF(soself->s_format, o_format);
|
||||
}
|
||||
else if (PyUnicode_Check(o_format)) {
|
||||
PyObject *str = PyUnicode_AsEncodedString(o_format, "ascii", NULL);
|
||||
if (str == NULL)
|
||||
return -1;
|
||||
Py_CLEAR(soself->s_format);
|
||||
soself->s_format = str;
|
||||
Py_SETREF(soself->s_format, str);
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
|
@ -62,9 +62,8 @@ BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
|
|||
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;
|
||||
}
|
||||
|
@ -279,9 +278,8 @@ BaseException_set_dict(PyBaseExceptionObject *self, PyObject *val)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -307,8 +305,7 @@ BaseException_set_args(PyBaseExceptionObject *self, PyObject *val)
|
|||
seq = PySequence_Tuple(val);
|
||||
if (!seq)
|
||||
return -1;
|
||||
Py_CLEAR(self->args);
|
||||
self->args = seq;
|
||||
Py_SETREF(self->args, seq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -608,19 +605,16 @@ EnvironmentError_init(PyEnvironmentErrorObject *self, PyObject *args,
|
|||
&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)
|
||||
|
@ -877,8 +871,7 @@ WindowsError_init(PyWindowsErrorObject *self, PyObject *args, PyObject *kwds)
|
|||
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)
|
||||
|
@ -1063,9 +1056,8 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds)
|
|||
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);
|
||||
|
@ -1080,21 +1072,17 @@ SyntaxError_init(PySyntaxErrorObject *self, PyObject *args, PyObject *kwds)
|
|||
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);
|
||||
}
|
||||
|
@ -1327,8 +1315,7 @@ set_string(PyObject **attr, const char *value)
|
|||
PyObject *obj = PyString_FromString(value);
|
||||
if (!obj)
|
||||
return -1;
|
||||
Py_CLEAR(*attr);
|
||||
*attr = obj;
|
||||
Py_SETREF(*attr, obj);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue