[Python-checkins] r62016 - in python/branches/release25-maint: Lib/test/test_compile.py Misc/NEWS Python/compile.c
amaury.forgeotdarc
python-checkins at python.org
Fri Mar 28 21:45:42 CET 2008
Author: amaury.forgeotdarc
Date: Fri Mar 28 21:45:42 2008
New Revision: 62016
Modified:
python/branches/release25-maint/Lib/test/test_compile.py
python/branches/release25-maint/Misc/NEWS
python/branches/release25-maint/Python/compile.c
Log:
Fix a reference leak found by Georg, when compiling a class nested in another class.
Test is run with "regrtest.py -R:: test_compile"
Backport of r62015
Modified: python/branches/release25-maint/Lib/test/test_compile.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_compile.py (original)
+++ python/branches/release25-maint/Lib/test/test_compile.py Fri Mar 28 21:45:42 2008
@@ -398,6 +398,10 @@
del d[..., ...]
self.assertEqual((Ellipsis, Ellipsis) in d, False)
+ def test_nested_classes(self):
+ # Verify that it does not leak
+ compile("class A:\n class B: pass", 'tmp', 'exec')
+
def test_main():
test_support.run_unittest(TestSpecifics)
Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS (original)
+++ python/branches/release25-maint/Misc/NEWS Fri Mar 28 21:45:42 2008
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- The compilation of a class nested in another class used to leak one
+ reference on the outer class name.
+
- Issue #1477: With narrow Unicode builds, the unicode escape sequence
\Uxxxxxxxx did not accept values outside the Basic Multilingual Plane. This
affected raw unicode literals and the 'raw-unicode-escape' codec. Now
Modified: python/branches/release25-maint/Python/compile.c
==============================================================================
--- python/branches/release25-maint/Python/compile.c (original)
+++ python/branches/release25-maint/Python/compile.c Fri Mar 28 21:45:42 2008
@@ -2061,6 +2061,7 @@
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__");
More information about the Python-checkins
mailing list