[Python-checkins] r42966 - in python/branches/release24-maint: Lib/test/test_hotshot.py Modules/_hotshot.c

tim.peters python-checkins at python.org
Sat Mar 11 05:55:46 CET 2006


Author: tim.peters
Date: Sat Mar 11 05:55:45 2006
New Revision: 42966
Modified:
 python/branches/release24-maint/Lib/test/test_hotshot.py
 python/branches/release24-maint/Modules/_hotshot.c
Log:
Merge rev 42904 from the trunk.
_hotshot hotshot_profiler(): If write_header() returned
an error code, this let `self` leak. This is a disaster
on Windows, since `self` already points to a newly-opened
file object, and it was impossible for Python code to
close the thing since the only reference to it was in a
blob of leaked C memory.
test_hotshot test_bad_sys_path(): This new test provoked
the C bug above. This test passed, but left an open
"@test" file behind, which caused a massive cascade of
bogus test failures in later, unrelated tests on Windows.
Changed the test code to remove the @test file it leaves
behind, which relies on the change above to close that
file first.
Modified: python/branches/release24-maint/Lib/test/test_hotshot.py
==============================================================================
--- python/branches/release24-maint/Lib/test/test_hotshot.py	(original)
+++ python/branches/release24-maint/Lib/test/test_hotshot.py	Sat Mar 11 05:55:45 2006
@@ -109,17 +109,20 @@
 
 def test_bad_sys_path(self):
 import sys
+ import os
 orig_path = sys.path
 coverage = hotshot._hotshot.coverage
 try:
 # verify we require a list for sys.path
 sys.path = 'abc'
 self.assertRaises(RuntimeError, coverage, test_support.TESTFN)
- # verify sys.path exists
+ # verify that we require sys.path exists
 del sys.path
 self.assertRaises(RuntimeError, coverage, test_support.TESTFN)
 finally:
 sys.path = orig_path
+ if os.path.exists(test_support.TESTFN):
+ os.remove(test_support.TESTFN)
 
 def test_main():
 test_support.run_unittest(HotShotTestCase)
Modified: python/branches/release24-maint/Modules/_hotshot.c
==============================================================================
--- python/branches/release24-maint/Modules/_hotshot.c	(original)
+++ python/branches/release24-maint/Modules/_hotshot.c	Sat Mar 11 05:55:45 2006
@@ -1556,9 +1556,11 @@
 calibrate();
 calibrate();
 }
- if (write_header(self))
+ if (write_header(self)) {
 /* some error occurred, exception has been set */
+ Py_DECREF(self);
 self = NULL;
+ }
 }
 return (PyObject *) self;
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /