mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
A couple of crashers of the "won't fix" kind.
This commit is contained in:
parent
999a336ad7
commit
d77ef8fa51
2 changed files with 26 additions and 0 deletions
9
Lib/test/crashers/bogus_code_obj.py
Normal file
9
Lib/test/crashers/bogus_code_obj.py
Normal file
|
|
@ -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
|
||||||
17
Lib/test/crashers/gc_inspection.py
Normal file
17
Lib/test/crashers/gc_inspection.py
Normal file
|
|
@ -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())
|
||||||
Loading…
Add table
Add a link
Reference in a new issue