]> granicus.if.org Git - python/commitdiff
Show case: reference cycles involving only the ob_type field are rather
authorArmin Rigo <arigo@tunes.org>
Fri, 14 Apr 2006 14:58:30 +0000 (14:58 +0000)
committerArmin Rigo <arigo@tunes.org>
Fri, 14 Apr 2006 14:58:30 +0000 (14:58 +0000)
uncommon but possible.  Inspired by SF bug 1469629.

Lib/test/leakers/test_selftype.py [new file with mode: 0644]

diff --git a/Lib/test/leakers/test_selftype.py b/Lib/test/leakers/test_selftype.py
new file mode 100644 (file)
index 0000000..4207c32
--- /dev/null
@@ -0,0 +1,13 @@
+# Reference cycles involving only the ob_type field are rather uncommon
+# but possible.  Inspired by SF bug 1469629.
+
+import gc
+
+def leak():
+    class T(type):
+        pass
+    class U(type):
+        __metaclass__ = T
+    U.__class__ = U
+    del U
+    gc.collect(); gc.collect(); gc.collect()