cpython: 9fb57c0209ea (original) (raw)
Mercurial > cpython
changeset 99684:9fb57c0209ea 3.5
Issue #20440: Applied yet one patch for using Py_SETREF. The patch is automatically generated, it replaces the code that uses Py_CLEAR. [#20440]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Sun, 27 Dec 2015 12:36:18 +0200 |
parents | 2af2367d7eda |
children | bc7c56a225de 4bfbb2714ae9 |
files | Modules/_bz2module.c Modules/_io/bufferedio.c Modules/_io/textio.c Modules/_lzmamodule.c Modules/_pickle.c Modules/_struct.c Modules/cjkcodecs/multibytecodec.c Modules/itertoolsmodule.c Objects/exceptions.c Objects/rangeobject.c Python/ceval.c |
diffstat | 11 files changed, 66 insertions(+), 109 deletions(-)[+] [-] Modules/_bz2module.c 5 Modules/_io/bufferedio.c 12 Modules/_io/textio.c 12 Modules/_lzmamodule.c 5 Modules/_pickle.c 8 Modules/_struct.c 3 Modules/cjkcodecs/multibytecodec.c 3 Modules/itertoolsmodule.c 57 Objects/exceptions.c 58 Objects/rangeobject.c 8 Python/ceval.c 4 |
line wrap: on
line diff
--- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -540,9 +540,8 @@ decompress(BZ2Decompressor *d, char *dat if (d->eof) { d->needs_input = 0; if (d->bzs_avail_in_real > 0) {
Py_CLEAR(d->unused_data);[](#l1.7)
d->unused_data = PyBytes_FromStringAndSize([](#l1.8)
bzs->next_in, d->bzs_avail_in_real);[](#l1.9)
Py_SETREF(d->unused_data,[](#l1.10)
PyBytes_FromStringAndSize(bzs->next_in, d->bzs_avail_in_real));[](#l1.11) if (d->unused_data == NULL)[](#l1.12) goto error;[](#l1.13) }[](#l1.14)
--- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1196,8 +1196,7 @@ found: Py_CLEAR(res); goto end; }
end: LEAVE_BUFFERED(self) @@ -1452,9 +1451,8 @@ static int if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1;
- Py_SETREF(self->raw, raw); self->buffer_size = buffer_size; self->readable = 1; self->writable = 0; @@ -1805,9 +1803,8 @@ static int if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1;
- Py_SETREF(self->raw, raw); self->readable = 0; self->writable = 1; @@ -2309,9 +2306,8 @@ static int if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1;
--- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -995,8 +995,7 @@ static int "Oi", self->decoder, (int)self->readtranslate); if (incrementalDecoder == NULL) goto error;
Py_CLEAR(self->decoder);[](#l3.7)
self->decoder = incrementalDecoder;[](#l3.8)
} @@ -1374,8 +1373,7 @@ static PyObject * static void textiowrapper_set_decoded_chars(textio *self, PyObject *chars) {Py_SETREF(self->decoder, incrementalDecoder);[](#l3.9) }[](#l3.10)
@@ -1523,8 +1521,7 @@ textiowrapper_read_chunk(textio self, P dec_buffer = NULL; / Reference lost to PyBytes_Concat */ goto fail; }
Py_CLEAR(self->snapshot);[](#l3.27)
self->snapshot = Py_BuildValue("NN", dec_flags, next_input);[](#l3.28)
} Py_DECREF(input_chunk); @@ -1630,8 +1627,7 @@ static PyObject * if (chunks != NULL) { if (result != NULL && PyList_Append(chunks, result) < 0) goto fail;Py_SETREF(self->snapshot, Py_BuildValue("NN", dec_flags, next_input));[](#l3.29)
Py_CLEAR(result);[](#l3.37)
result = PyUnicode_Join(_PyIO_empty_str, chunks);[](#l3.38)
Py_SETREF(result, PyUnicode_Join(_PyIO_empty_str, chunks));[](#l3.39) if (result == NULL)[](#l3.40) goto fail;[](#l3.41) Py_CLEAR(chunks);[](#l3.42)
--- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -1011,9 +1011,8 @@ decompress(Decompressor *d, uint8_t *dat if (d->eof) { d->needs_input = 0; if (lzs->avail_in > 0) {
Py_CLEAR(d->unused_data);[](#l4.7)
d->unused_data = PyBytes_FromStringAndSize([](#l4.8)
(char *)lzs->next_in, lzs->avail_in);[](#l4.9)
Py_SETREF(d->unused_data,[](#l4.10)
PyBytes_FromStringAndSize((char *)lzs->next_in, lzs->avail_in));[](#l4.11) if (d->unused_data == NULL)[](#l4.12) goto error;[](#l4.13) }[](#l4.14)
--- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -846,9 +846,8 @@ PyMemoTable_Set(PyMemoTable *self, PyObj static int _Pickler_ClearBuffer(PicklerObject *self) {
- Py_CLEAR(self->output_buffer);
- self->output_buffer =
PyBytes_FromStringAndSize(NULL, self->max_output_len);[](#l5.9)
- Py_SETREF(self->output_buffer,
if (self->output_buffer == NULL) return -1; self->output_len = 0; @@ -3089,9 +3088,8 @@ fix_imports(PyObject **module_name, PyOb Py_TYPE(item)->tp_name); return -1; }PyBytes_FromStringAndSize(NULL, self->max_output_len));[](#l5.11)
Py_CLEAR(*module_name);[](#l5.19) Py_INCREF(item);[](#l5.20)
*module_name = item;[](#l5.21)
--- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1437,8 +1437,7 @@ s_init(PyObject *self, PyObject *args, P return -1; }
ret = prepare_s(soself); return ret;
--- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -793,8 +793,7 @@ encoder_encode_stateful(MultibyteStatefu ctx->errors, final ? MBENC_FLUSH | MBENC_RESET : 0); if (r == NULL) { /* recover the original pending buffer */
Py_CLEAR(ctx->pending);[](#l7.7)
ctx->pending = origpending;[](#l7.8)
}Py_SETREF(ctx->pending, origpending);[](#l7.9) origpending = NULL;[](#l7.10) goto errorexit;[](#l7.11)
--- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -159,15 +159,12 @@ groupby_setstate(groupbyobject *lz, PyOb PyObject *currkey, *currvalue, *tgtkey; if (!PyArg_ParseTuple(state, "OOO", &currkey, &currvalue, &tgtkey)) return NULL;
- Py_CLEAR(lz->currkey);
- lz->currkey = currkey;
- Py_INCREF(lz->currkey);
- Py_CLEAR(lz->currvalue);
- lz->currvalue = currvalue;
- Py_INCREF(lz->currvalue);
- Py_CLEAR(lz->tgtkey);
- lz->tgtkey = tgtkey;
- Py_INCREF(lz->tgtkey);
- Py_INCREF(currkey);
- Py_SETREF(lz->currkey, currkey);
- Py_INCREF(currvalue);
- Py_SETREF(lz->currvalue, currvalue);
- Py_INCREF(tgtkey);
- Py_SETREF(lz->tgtkey, tgtkey); Py_RETURN_NONE; }
@@ -747,9 +744,8 @@ tee_setstate(teeobject *to, PyObject *st PyErr_SetString(PyExc_ValueError, "Index out of range"); return NULL; }
@@ -974,9 +970,8 @@ cycle_setstate(cycleobject *lz, PyObject int firstpass; if (!PyArg_ParseTuple(state, "Oi", &saved, &firstpass)) return NULL;
@@ -1901,12 +1896,10 @@ chain_setstate(chainobject *lz, PyObject if (! PyArg_ParseTuple(state, "O|O", &source, &active)) return NULL;
- Py_CLEAR(lz->source);
- lz->source = source;
- Py_INCREF(lz->source);
- Py_CLEAR(lz->active);
- lz->active = active;
- Py_XINCREF(lz->active);
- Py_INCREF(source);
- Py_SETREF(lz->source, source);
- Py_XINCREF(active);
- Py_SETREF(lz->active, active); Py_RETURN_NONE; }
@@ -2262,8 +2255,7 @@ product_setstate(productobject *lz, PyOb Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); }
@@ -2585,8 +2577,7 @@ combinations_setstate(combinationsobject PyTuple_SET_ITEM(result, i, element); }
@@ -2916,8 +2907,7 @@ cwr_setstate(cwrobject *lz, PyObject *st Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); }
@@ -3310,8 +3300,7 @@ permutations_setstate(permutationsobject Py_INCREF(element); PyTuple_SET_ITEM(result, i, element); }
@@ -3481,9 +3470,8 @@ accumulate_reduce(accumulateobject *lz) static PyObject * accumulate_setstate(accumulateobject *lz, PyObject *state) {
@@ -4464,9 +4452,8 @@ zip_longest_reduce(ziplongestobject *lz) static PyObject * zip_longest_setstate(ziplongestobject *lz, PyObject *state) {
--- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -206,8 +206,7 @@ BaseException_set_args(PyBaseExceptionOb seq = PySequence_Tuple(val); if (!seq) return -1;
@@ -646,9 +645,8 @@ ImportError_init(PyImportErrorObject *se if (!PyArg_UnpackTuple(args, "ImportError", 1, 1, &msg)) return -1;
return 0; } @@ -858,8 +856,7 @@ oserror_init(PyOSErrorObject self, PyOb #endif / Steals the reference to args */
- Py_SETREF(self->args, args); *p_args = args = NULL; return 0; @@ -1278,9 +1275,8 @@ SyntaxError_init(PySyntaxErrorObject *se return -1;
Py_CLEAR(self->msg);[](#l9.39)
self->msg = PyTuple_GET_ITEM(args, 0);[](#l9.40)
Py_INCREF(self->msg);[](#l9.41)
Py_INCREF(PyTuple_GET_ITEM(args, 0));[](#l9.42)
} if (lenargs == 2) { info = PyTuple_GET_ITEM(args, 1);Py_SETREF(self->msg, PyTuple_GET_ITEM(args, 0));[](#l9.43)
@@ -1295,21 +1291,17 @@ SyntaxError_init(PySyntaxErrorObject *se return -1; }
Py_CLEAR(self->filename);[](#l9.51)
self->filename = PyTuple_GET_ITEM(info, 0);[](#l9.52)
Py_INCREF(self->filename);[](#l9.53)
Py_CLEAR(self->lineno);[](#l9.55)
self->lineno = PyTuple_GET_ITEM(info, 1);[](#l9.56)
Py_INCREF(self->lineno);[](#l9.57)
Py_CLEAR(self->offset);[](#l9.59)
self->offset = PyTuple_GET_ITEM(info, 2);[](#l9.60)
Py_INCREF(self->offset);[](#l9.61)
Py_CLEAR(self->text);[](#l9.63)
self->text = PyTuple_GET_ITEM(info, 3);[](#l9.64)
Py_INCREF(self->text);[](#l9.65)
Py_INCREF(PyTuple_GET_ITEM(info, 0));[](#l9.66)
Py_SETREF(self->filename, PyTuple_GET_ITEM(info, 0));[](#l9.67)
Py_INCREF(PyTuple_GET_ITEM(info, 1));[](#l9.69)
Py_SETREF(self->lineno, PyTuple_GET_ITEM(info, 1));[](#l9.70)
Py_INCREF(PyTuple_GET_ITEM(info, 2));[](#l9.72)
Py_SETREF(self->offset, PyTuple_GET_ITEM(info, 2));[](#l9.73)
Py_INCREF(PyTuple_GET_ITEM(info, 3));[](#l9.75)
Py_SETREF(self->text, PyTuple_GET_ITEM(info, 3));[](#l9.76)
Py_DECREF(info); @@ -1554,8 +1546,7 @@ set_unicodefromstring(PyObject **attr, c PyObject *obj = PyUnicode_FromString(value); if (!obj) return -1;
@@ -1961,8 +1952,7 @@ UnicodeDecodeError_init(PyObject *self, Py_buffer view; if (PyObject_GetBuffer(ude->object, &view, PyBUF_SIMPLE) != 0) goto error;
Py_CLEAR(ude->object);[](#l9.94)
ude->object = PyBytes_FromStringAndSize(view.buf, view.len);[](#l9.95)
Py_SETREF(ude->object, PyBytes_FromStringAndSize(view.buf, view.len));[](#l9.96) PyBuffer_Release(&view);[](#l9.97) if (!ude->object)[](#l9.98) goto error;[](#l9.99)
@@ -2871,9 +2861,8 @@ static int } if (PyUnicode_Tailmatch(self->text, print_prefix, start, text_len, -1)) {
Py_CLEAR(self->msg);[](#l9.104)
self->msg = PyUnicode_FromString([](#l9.105)
"Missing parentheses in call to 'print'");[](#l9.106)
Py_SETREF(self->msg,[](#l9.107)
} @@ -2886,9 +2875,8 @@ static int } if (PyUnicode_Tailmatch(self->text, exec_prefix, start, text_len, -1)) {PyUnicode_FromString("Missing parentheses in call to 'print'"));[](#l9.108) return 1;[](#l9.109)
Py_CLEAR(self->msg);[](#l9.116)
self->msg = PyUnicode_FromString([](#l9.117)
"Missing parentheses in call to 'exec'");[](#l9.118)
Py_SETREF(self->msg,[](#l9.119)
} /* Fall back to the default error message */PyUnicode_FromString("Missing parentheses in call to 'exec'"));[](#l9.120) return 1;[](#l9.121)
--- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -1001,8 +1001,7 @@ longrangeiter_setstate(longrangeiterobje return NULL; cmp = PyObject_RichCompareBool(state, zero, Py_LT); if (cmp > 0) {
Py_CLEAR(r->index);[](#l10.7)
r->index = zero;[](#l10.8)
} Py_DECREF(zero); @@ -1015,9 +1014,8 @@ longrangeiter_setstate(longrangeiterobje if (cmp > 0) state = r->len;Py_SETREF(r->index, zero);[](#l10.9) Py_RETURN_NONE;[](#l10.10)
--- a/Python/ceval.c +++ b/Python/ceval.c @@ -4410,10 +4410,8 @@ void { PyThreadState *tstate = PyThreadState_GET();