]> granicus.if.org Git - python/commitdiff
A couple of crashers of the "won't fix" kind.
authorArmin Rigo <arigo@tunes.org>
Wed, 28 Jun 2006 10:49:51 +0000 (10:49 +0000)
committerArmin Rigo <arigo@tunes.org>
Wed, 28 Jun 2006 10:49:51 +0000 (10:49 +0000)
Lib/test/crashers/bogus_code_obj.py [new file with mode: 0644]
Lib/test/crashers/gc_inspection.py [new file with mode: 0644]

diff --git a/Lib/test/crashers/bogus_code_obj.py b/Lib/test/crashers/bogus_code_obj.py
new file mode 100644 (file)
index 0000000..5438d91
--- /dev/null
@@ -0,0 +1,9 @@
+"""
+Broken bytecode objects can easily crash the interpreter.
+"""
+
+import types
+
+co = types.CodeType(0, 0, 0, 0, '\x04\x71\x00\x00', (),
+                    (), (), '', '', 1, '')
+exec co
diff --git a/Lib/test/crashers/gc_inspection.py b/Lib/test/crashers/gc_inspection.py
new file mode 100644 (file)
index 0000000..b439ad9
--- /dev/null
@@ -0,0 +1,17 @@
+"""
+gc.get_referrers() can be used to see objects before they are fully built.
+"""
+
+import gc
+
+
+def g():
+    marker = object()
+    yield marker
+    # now the marker is in the tuple being constructed
+    [tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple]
+    print tup
+    print tup[1]
+
+
+tuple(g())