def testExceptionRefCounting( self ) :

		class T( object ) :

			def __init__( self, s ) :

				# note the use of Gaffer.WeakMethod to avoid creating a circular reference
				# from self -> self.connection -> self.callback -> self. this is critical
				# when connecting methods of class to a signal.
				self.connection = s.memberAddedSignal().connect( Gaffer.WeakMethod( self.callback ) )

			def callback( self, s, n ) :

				raise Exception

		s = Gaffer.StandardSet()
		t = T( s )
		w = weakref.ref( t )

		realStdErr = sys.stderr
		sio = StringIO.StringIO()
		try :
			sys.stderr = sio
			s.add( Gaffer.Node() )
		finally :
			sys.stderr = realStdErr

		del t

		self.assert_( w() is None )
		self.assert_( "Exception" in sio.getvalue() )
dataset/ETHPy150Open ImageEngine/gaffer/python/GafferTest/SignalsTest.py/SignalsTest.testExceptionRefCounting/original