Issue #20440: Massive replacing unsafe attribute setting code with special

macro Py_SETREF.
This commit is contained in:
Serhiy Storchaka 2015-12-24 10:35:59 +02:00
parent a198645fa0
commit 5a57ade58e
28 changed files with 92 additions and 120 deletions

View file

@ -680,8 +680,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
goto handle_error;
}
else if (!is_true) {
Py_DECREF(*filename);
*filename = PyUnicode_FromString("__main__");
Py_SETREF(*filename, PyUnicode_FromString("__main__"));
if (*filename == NULL)
goto handle_error;
}

View file

@ -3214,8 +3214,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
Py_INCREF(self);
func = PyMethod_GET_FUNCTION(func);
Py_INCREF(func);
Py_DECREF(*pfunc);
*pfunc = self;
Py_SETREF(*pfunc, self);
na++;
/* n++; */
} else
@ -4670,8 +4669,7 @@ call_function(PyObject ***pp_stack, int oparg
Py_INCREF(self);
func = PyMethod_GET_FUNCTION(func);
Py_INCREF(func);
Py_DECREF(*pfunc);
*pfunc = self;
Py_SETREF(*pfunc, self);
na++;
n++;
} else

View file

@ -1795,8 +1795,7 @@ compiler_class(struct compiler *c, stmt_ty s)
{
/* use the class name for name mangling */
Py_INCREF(s->v.ClassDef.name);
Py_XDECREF(c->u->u_private);
c->u->u_private = s->v.ClassDef.name;
Py_SETREF(c->u->u_private, s->v.ClassDef.name);
/* load (global) __name__ ... */
str = PyUnicode_InternFromString("__name__");
if (!str || !compiler_nameop(c, str, Load)) {