tclass.py 959 B

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