]> granicus.if.org Git - python/commitdiff
Fix a reference leak found by Georg, when compiling a class nested in another class.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Fri, 28 Mar 2008 20:30:50 +0000 (20:30 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Fri, 28 Mar 2008 20:30:50 +0000 (20:30 +0000)
Now "regrtest.py -R:: test_compile" is satisfied.

Will backport.

Misc/NEWS
Python/compile.c

index 7c413d683e782da73dfe6f21587e1f6fd18dba2a..893b8ac5c016a98d8b0207ecf548cb8c437c94b3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
 Core and builtins
 -----------------
 
+- The compilation of a class nested in another class used to leak one
+  reference on the outer class name.
+
 - Patch #1810: compile() can now compile _ast trees as returned by
   compile(..., PyCF_ONLY_AST).
 
index 4f55b36fdd38502f93ce951b1b56ab3b6c4aee38..ae1f0da89761a4ed334156367237f03e4a7cc46d 100644 (file)
@@ -1431,6 +1431,7 @@ compiler_class(struct compiler *c, stmt_ty s)
        if (!compiler_enter_scope(c, s->v.ClassDef.name, (void *)s,
                                  s->lineno))
                return 0;
+       Py_XDECREF(c->u->u_private);
        c->u->u_private = s->v.ClassDef.name;
        Py_INCREF(c->u->u_private);
        str = PyString_InternFromString("__name__");