Message9657

Author stefan.richthofer
Recipients Arfrever, stefan.richthofer, zyasoft
Date 2015-03-15.23:22:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426461722.27.0.354194660185.issue2288@psf.upfronthosting.co.za>
In-reply-to
Content
I tried to compare current Jython exception-in-__del__ behavior to that of CPython. Of course, in CPython one cannot produce Java NullPointerExceptions, so I rewrote the test to use an ordinary python exception by calling "print None.test":

class GCTests_Finalization_Exception_CPythonCompliant(unittest.TestCase):

    def test1(self):
        class A:
            def __del__(self):
                print "A __del__"
                A.txt = "text1"
                print None.test
                A.txt = "text2"

        a = A()
        del a
        gc.collect()
        time.sleep(1)
        print "collect done"
        print A.txt
        self.assertEqual(A.txt, "text1")

if __name__ == "__main__":
    unittest.main()


The output of Jython is in principal equal that of CPython.
CPython:

A __del__
Exception AttributeError: "'NoneType' object has no attribute 'test'" in <bound method A.__del__ of <__main__.A instance at 0x166dd88>> ignored
collect done
text1
.
----------------------------------------------------------------------
Ran 1 test in 1.005s

OK


Jython:

A __del__
Exception AttributeError: "'NoneType' object has no attribute 'test'" in <bound method A.__del__ of <__main__.A instance at 0x2>> ignored
collect done
text1
.
----------------------------------------------------------------------
Ran 1 test in 1.309s

OK


So I seriously doubt that the error is finalization-related at all.
tbc
History
Date User Action Args
2015-03-15 23:22:02stefan.richthofersetmessageid: <1426461722.27.0.354194660185.issue2288@psf.upfronthosting.co.za>
2015-03-15 23:22:02stefan.richthofersetrecipients: + stefan.richthofer, zyasoft, Arfrever
2015-03-15 23:22:02stefan.richthoferlinkissue2288 messages
2015-03-15 23:22:01stefan.richthofercreate