]> granicus.if.org Git - python/commitdiff
Issue #5635: Fix running test_sys with tracing enabled.
authorGeorg Brandl <georg@python.org>
Wed, 1 Apr 2009 00:04:33 +0000 (00:04 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 1 Apr 2009 00:04:33 +0000 (00:04 +0000)
Lib/test/test_sys.py
Misc/NEWS

index a4554a67ba6bec4aa91c309dd9bb00c5ba96bf24..afeaf251b1c62ed1fbb62fb6f97eefb846d109ca 100644 (file)
@@ -221,6 +221,11 @@ class SysModuleTest(unittest.TestCase):
             sys.setdlopenflags(oldflags)
 
     def test_refcount(self):
+        # n here 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.
+        global n
         self.assertRaises(TypeError, sys.getrefcount)
         c = sys.getrefcount(None)
         n = None
index 62b37f211a5663fd589281a3ac6f051b81e144a7..6907c97853d310bfae2fa0ed53c9623f079960f1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1,4 +1,5 @@
-+++++++++++ Python News
++++++++++++
+Python News
 +++++++++++
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
@@ -715,6 +716,8 @@ Extension Modules
 Tests
 -----
 
+- Issue #5635: Fix running test_sys with tracing enabled.
+
 - regrtest no longer treats ImportError as equivalent to SkipTest.  Imports
   that should cause a test to be skipped are now done using import_module 
   from test support, which does the conversion.