cpython: 4bfbb2714ae9 (original) (raw)
Mercurial > cpython
changeset 99687:4bfbb2714ae9 3.5
Issue #20440: More use of Py_SETREF. This patch is manually crafted and contains changes that couldn't be handled automatically. [#20440]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Sun, 27 Dec 2015 15:41:34 +0200 |
parents | 9fb57c0209ea |
children | 539ba7267701 5114871a3ac6 |
files | Modules/_ctypes/_ctypes.c Modules/_elementtree.c Modules/_sqlite/cursor.c Modules/zlibmodule.c Objects/exceptions.c Objects/unicodeobject.c Python/errors.c |
diffstat | 7 files changed, 39 insertions(+), 58 deletions(-)[+] [-] Modules/_ctypes/_ctypes.c 3 Modules/_elementtree.c 38 Modules/_sqlite/cursor.c 4 Modules/zlibmodule.c 18 Objects/exceptions.c 19 Objects/unicodeobject.c 2 Python/errors.c 13 |
line wrap: on
line diff
--- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2983,10 +2983,9 @@ PyCFuncPtr_set_restype(PyCFuncPtrObject "restype must be a type, a callable, or None"); return -1; }
- Py_XDECREF(self->checker); Py_INCREF(ob); Py_SETREF(self->restype, ob);
- self->checker = PyObject_GetAttrString(ob, "check_retval");
- Py_SETREF(self->checker, PyObject_GetAttrString(ob, "check_retval")); if (self->checker == NULL) PyErr_Clear(); return 0;
--- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -935,9 +935,8 @@ element_setstate_from_attributes(Element return NULL; }
_clear_joined_ptr(&self->text); self->text = text ? JOIN_SET(text, PyList_CheckExact(text)) : Py_None; @@ -980,9 +979,8 @@ element_setstate_from_attributes(Element /* Stash attrib. */ if (attrib) {
Py_CLEAR(self->extra->attrib);[](#l2.19)
self->extra->attrib = attrib;[](#l2.20) Py_INCREF(attrib);[](#l2.21)
} Py_RETURN_NONE; @@ -1944,9 +1942,8 @@ element_setattro(ElementObject* self, Py return -1;Py_SETREF(self->extra->attrib, attrib);[](#l2.22)
if (strcmp(name, "tag") == 0) {
Py_DECREF(self->tag);[](#l2.30)
self->tag = value;[](#l2.31)
Py_INCREF(self->tag);[](#l2.32)
Py_INCREF(value);[](#l2.33)
} else if (strcmp(name, "text") == 0) { Py_DECREF(JOIN_OBJ(self->text)); self->text = value;Py_SETREF(self->tag, value);[](#l2.34)
@@ -1960,9 +1957,8 @@ element_setattro(ElementObject* self, Py if (create_extra(self, NULL) < 0) return -1; }
Py_DECREF(self->extra->attrib);[](#l2.42)
self->extra->attrib = value;[](#l2.43)
Py_INCREF(self->extra->attrib);[](#l2.44)
Py_INCREF(value);[](#l2.45)
} else { PyErr_SetString(PyExc_AttributeError, "Can't set arbitrary attributes on Element");Py_SETREF(self->extra->attrib, value);[](#l2.46)
@@ -2554,13 +2550,10 @@ treebuilder_handle_start(TreeBuilderObje } self->index++;
if (treebuilder_append_event(self, self->start_event_obj, node) < 0) goto error; @@ -2633,15 +2626,12 @@ treebuilder_handle_end(TreeBuilderObject return NULL; }
if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0) return NULL;
--- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -524,10 +524,10 @@ PyObject* _pysqlite_query_execute(pysqli if (self->statement) { (void)pysqlite_statement_reset(self->statement);
}Py_DECREF(self->statement);[](#l3.7)
- self->statement = (pysqlite_Statement*)pysqlite_cache_get(self->connection->statement_cache, func_args);
- Py_SETREF(self->statement,
Py_DECREF(func_args); if (!self->statement) {(pysqlite_Statement *)pysqlite_cache_get(self->connection->statement_cache, func_args));[](#l3.12)
--- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -961,14 +961,11 @@ zlib_Compress_copy_impl(compobject *self goto error; } Py_INCREF(self->unused_data);
- Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail);
- Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); Py_XINCREF(self->zdict);
- Py_XDECREF(retval->unused_data);
- Py_XDECREF(retval->unconsumed_tail);
- Py_XDECREF(retval->zdict);
- retval->unused_data = self->unused_data;
- retval->unconsumed_tail = self->unconsumed_tail;
- retval->zdict = self->zdict;
- Py_SETREF(retval->zdict, self->zdict); retval->eof = self->eof; /* Mark it as being initialized */ @@ -1020,14 +1017,11 @@ zlib_Decompress_copy_impl(compobject *se } Py_INCREF(self->unused_data);
- Py_SETREF(retval->unused_data, self->unused_data); Py_INCREF(self->unconsumed_tail);
- Py_SETREF(retval->unconsumed_tail, self->unconsumed_tail); Py_XINCREF(self->zdict);
- Py_XDECREF(retval->unused_data);
- Py_XDECREF(retval->unconsumed_tail);
- Py_XDECREF(retval->zdict);
- retval->unused_data = self->unused_data;
- retval->unconsumed_tail = self->unconsumed_tail;
- retval->zdict = self->zdict;
--- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -561,12 +561,14 @@ SystemExit_init(PySystemExitObject *self if (size == 0) return 0;
- Py_CLEAR(self->code);
- if (size == 1)
self->code = PyTuple_GET_ITEM(args, 0);[](#l5.9)
- else /* size > 1 */
self->code = args;[](#l5.11)
- Py_INCREF(self->code);
- if (size == 1) {
Py_INCREF(PyTuple_GET_ITEM(args, 0));[](#l5.14)
Py_SETREF(self->code, PyTuple_GET_ITEM(args, 0));[](#l5.15)
- }
- else { /* size > 1 */
Py_INCREF(args);[](#l5.18)
Py_SETREF(self->code, args);[](#l5.19)
- } return 0; }
@@ -625,9 +627,8 @@ ImportError_init(PyImportErrorObject *se #define GET_KWD(kwd) { [](#l5.25) kwd = PyDict_GetItemString(kwds, #kwd); [](#l5.26) if (kwd) { [](#l5.27)
Py_CLEAR(self->kwd); \[](#l5.28)
self->kwd = kwd; \[](#l5.29)
Py_INCREF(self->kwd);\[](#l5.30)
Py_INCREF(kwd); \[](#l5.31)
} [](#l5.35)Py_SETREF(self->kwd, kwd); \[](#l5.32) if (PyDict_DelItemString(kwds, #kwd)) \[](#l5.33) return -1; \[](#l5.34)
--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -14191,8 +14191,8 @@ unicode_format_arg_parse(struct unicode_ if (key == NULL) return -1; if (ctx->args_owned) {
ctx->args_owned = 0;[](#l6.7) Py_DECREF(ctx->args);[](#l6.8)
ctx->args_owned = 0;[](#l6.9) }[](#l6.10) ctx->args = PyObject_GetItem(ctx->dict, key);[](#l6.11) Py_DECREF(key);[](#l6.12)
--- a/Python/errors.c +++ b/Python/errors.c @@ -315,14 +315,11 @@ finally: tstate = PyThreadState_GET(); if (++tstate->recursion_depth > Py_GetRecursionLimit()) { --tstate->recursion_depth;
/* throw away the old exception... */[](#l7.7)
Py_DECREF(*exc);[](#l7.8)
Py_DECREF(*val);[](#l7.9)
/* ... and use the recursion error instead */[](#l7.10)
*exc = PyExc_RecursionError;[](#l7.11)
*val = PyExc_RecursionErrorInst;[](#l7.12)
Py_INCREF(*exc);[](#l7.13)
Py_INCREF(*val);[](#l7.14)
/* throw away the old exception and use the recursion error instead */[](#l7.15)
Py_INCREF(PyExc_RecursionError);[](#l7.16)
Py_SETREF(*exc, PyExc_RecursionError);[](#l7.17)
Py_INCREF(PyExc_RecursionErrorInst);[](#l7.18)
}Py_SETREF(*val, PyExc_RecursionErrorInst);[](#l7.19) /* just keeping the old traceback */[](#l7.20) return;[](#l7.21)