[3.6] bpo-23890: Fix ref cycles in TestCase.assertRaises() by vstinner · Pull Request #858 · python/cpython (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reference cycle when using the context manager protocol.

It seems like bpo-23890 was very specific to the function API: assertRaises(ValueError, func) since you pass func to assertRaises().

with self.assertRaises(ValueError):
    func()

Here func variable may also leak in the traceback objects linked to the raisen exception. But again, I'm unable to see any leak here without my fix.

If you still consider that an unit test is needed, please comment http://bugs.python.org/issue23890