1 """Simple script to be run *twice*, to check reference counting bugs. 2 3 See test_run for details.""" 4 5 6 import sys 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 try: 22 name = sys.argv[1] 23 except IndexError: 24 pass 25 else: 26 if name.startswith('C'): 27 c = C(name) 28 29 # print("ARGV:", sys.argv, file=sys.stderr) # dbg 30 31 # This next print statement is NOT debugging, we're making the check on a 32 # completely separate process so we verify by capturing stdout: 33 print('ARGV 1-:', sys.argv[1:]) 34 sys.stdout.flush() 35