| 1 |
"""Simple script to be run *twice*, to check reference counting bugs. |
| 2 |
|
| 3 |
See test_run for details.""" |
| 4 |
|
| 5 |
import sys |
| 6 |
|
| 7 |
|
| 8 |
# We want to ensure that while objects remain available for immediate access, |
| 9 |
# objects from *previous* runs of the same script get collected, to avoid |
| 10 |
# accumulating massive amounts of old references. |
| 11 |
class C(object): |
| 12 |
def __init__(self, name): |
| 13 |
self.name = name |
| 14 |
self.p = print |
| 15 |
self.flush_stdout = sys.stdout.flush |
| 16 |
|
| 17 |
def __del__(self): |
| 18 |
self.p("tclass.py: deleting object:", self.name) |
| 19 |
self.flush_stdout() |
| 20 |
|
| 21 |
|
| 22 |
try: |
| 23 |
name = sys.argv[1] |
| 24 |
except IndexError: |
| 25 |
pass |
| 26 |
else: |
| 27 |
if name.startswith("C"): |
| 28 |
c = C(name) |
| 29 |
|
| 30 |
# print("ARGV:", sys.argv, file=sys.stderr) # dbg |
| 31 |
|
| 32 |
# This next print statement is NOT debugging, we're making the check on a |
| 33 |
# completely separate process so we verify by capturing stdout: |
| 34 |
print("ARGV 1-:", sys.argv[1:]) |
| 35 |
sys.stdout.flush() |