On some systems (e.g., Ubuntu on hppa) the flush()
doesn't cause the exception, but the close() does.

Will backport.
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 09ac4d5..3ff31bb 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -53,6 +53,9 @@
                     try:
                         f.write("Y")
                         f.flush()
+                        # On some systems (e.g., Ubuntu on hppa) the flush()
+                        # doesn't cause the exception, but the close() does.
+                        f.close()
                     except IOError:
                         if not limit_set:
                             raise