Index: Lib/test/test_sys.py =================================================================== --- Lib/test/test_sys.py (revision 70696) +++ Lib/test/test_sys.py (working copy) @@ -221,6 +221,13 @@ sys.setdlopenflags(oldflags) def test_refcount(self): + global n + # n must be a global in order for this test to + # pass while tracing with a python function. + # Tracing calls PyFrame_FastToLocals which + # will add a copy of any locals to the frame object, + # causing the reference count to increase by 2 instead + # of 1. self.assertRaises(TypeError, sys.getrefcount) c = sys.getrefcount(None) n = None