classification
Title: AST nodes do not support garbage collection
Type: resource usage Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, flox, neologix, pitrou, python-dev
Priority: normal Keywords:

Created on 2012-07-08 10:47 by pitrou, last changed 2014-05-24 22:13 by benjamin.peterson. This issue is now closed.

Messages (4)
msg165001 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-07-08 10:47
Add the following to test_ast:

diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -199,6 +199,7 @@ class AST_Tests(unittest.TestCase):
         x.foobar = 42
         self.assertEqual(x.foobar, 42)
         self.assertEqual(x.__dict__["foobar"], 42)
+        x.x = x
 
         with self.assertRaises(AttributeError):
             x.vararg


and you'll get a reference leak.
msg165030 - (view) Author: Roundup Robot (python-dev) Date: 2012-07-08 18:03
New changeset 85cccc38d01c by Benjamin Peterson in branch 'default':
add gc support to the AST base type (closes #15293)
http://hg.python.org/cpython/rev/85cccc38d01c
msg218908 - (view) Author: Charles-Fran├žois Natali (neologix) * (Python committer) Date: 2014-05-22 18:38
Would it be possible to backport this to 2.7?
We've been bitten by this at work (pyflakes introduces reference cycles in AST).
msg219059 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2014-05-24 22:13
How are you reproducing the bug? In Python 2, the AST base class doesn't have a __dict__, and it's subtypes do support GC.
History
Date User Action Args
2014-05-24 22:13:51benjamin.petersonsetmessages: + msg219059
2014-05-22 19:05:56floxsetnosy: + flox
2014-05-22 18:38:33neologixsetnosy: + neologix
messages: + msg218908
2012-07-08 18:03:53python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg165030

resolution: fixed
stage: resolved
2012-07-08 10:47:33pitroucreate