Variety of small INC/DECREF patches that fix reported memory leaks
with free variables.  Thanks to Martin v. Loewis for finding two of
the problems.  This fixes SF buf 405583.

There is also a C API change: PyFrame_New() is reverting to its
pre-2.1 signature.  The change introduced by nested scopes was a
mistake.  XXX Is this okay between beta releases?

cell_clear(), the GC helper, must decref its reference to break
cycles.

frame_dealloc() must dealloc all cell vars and free vars in addition
to locals.

eval_code2() setup code must INCREF cells it copies out of the
closure.

The STORE_DEREF opcode implementation must DECREF the object it passes
to PyCell_Set().
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index d9ecfd7..66fc8d1 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -83,6 +83,7 @@
 static int
 cell_clear(PyCellObject *op)
 {
+	Py_XDECREF(op->ob_ref);
 	op->ob_ref = NULL;
 	return 0;
 }
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 18fb0b0..a5300d1 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -65,13 +65,14 @@
 static void
 frame_dealloc(PyFrameObject *f)
 {
-	int i;
+	int i, slots;
 	PyObject **fastlocals;
 
 	Py_TRASHCAN_SAFE_BEGIN(f)
 	/* Kill all local variables */
+	slots = f->f_nlocals + f->f_ncells + f->f_nfreevars;
 	fastlocals = f->f_localsplus;
-	for (i = f->f_nlocals; --i >= 0; ++fastlocals) {
+	for (i = slots; --i >= 0; ++fastlocals) {
 		Py_XDECREF(*fastlocals);
 	}
 
@@ -108,7 +109,7 @@
 
 PyFrameObject *
 PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals, 
-	    PyObject *locals, PyObject *closure)
+	    PyObject *locals)
 {
 	PyFrameObject *back = tstate->frame;
 	static PyObject *builtin_object;