[Python-checkins] r60727 - python/branches/release25-maint/Lib/test/test_resource.py
nick.coghlan
python-checkins at python.org
Mon Feb 11 12:31:24 CET 2008
Author: nick.coghlan
Date: Mon Feb 11 12:31:24 2008
New Revision: 60727
Modified:
python/branches/release25-maint/Lib/test/test_resource.py
Log:
Backport test_resource fix from trunk to stop it crashing on Ubuntu
Modified: python/branches/release25-maint/Lib/test/test_resource.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_resource.py (original)
+++ python/branches/release25-maint/Lib/test/test_resource.py Mon Feb 11 12:31:24 2008
@@ -32,23 +32,28 @@
except ValueError:
limit_set = 0
f = open(TESTFN, "wb")
- f.write("X" * 1024)
- f.flush()
try:
- f.write("Y")
- f.flush()
- # On some systems (e.g., Ubuntu on hppa) the flush()
- # doesn't always cause the exception, but the close()
- # does eventually. Try flushing several times in an attempt
- # to ensure the file is really synced and the exception raised.
- for i in range(5):
- time.sleep(.1)
+ f.write("X" * 1024)
+ try:
+ f.write("Y")
f.flush()
+ # On some systems (e.g., Ubuntu on hppa) the flush()
+ # doesn't always cause the exception, but the close()
+ # does eventually. Try flushing several times in
+ # an attempt to ensure the file is really synced and
+ # the exception raised.
+ for i in range(5):
+ time.sleep(.1)
+ f.flush()
+ except IOError:
+ if not limit_set:
+ raise
+ if limit_set:
+ # Close will attempt to flush the byte we wrote
+ # Restore limit first to avoid getting a spurious error
+ resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
+ finally:
f.close()
- except IOError:
- if not limit_set:
- raise
- f.close()
finally:
if limit_set:
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
More information about the Python-checkins
mailing list