[Zope3-checkins] SVN: Zope3/trunk/src/zope/publisher/tests/test_http.py getCacheStreamValue(): This caused the tests that used it

Tim Peters tim.one at comcast.net
Tue Oct 11 16:16:06 EDT 2005


Log message for revision 39071:
  getCacheStreamValue():  This caused the tests that used it
  to (indirectly) mix reading with writing on a file opened for
  update without an explicit file-positioning operation when
  switching between reading and writing.  All behavior is
  undefined (according to the C standard) then, and at least
  on Windows it frequently provoked mysterious IOError
  exceptions.
  
  All tests on Windows pass now.
  

Changed:
  U   Zope3/trunk/src/zope/publisher/tests/test_http.py

-=-
Modified: Zope3/trunk/src/zope/publisher/tests/test_http.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_http.py	2005-10-11 19:55:47 UTC (rev 39070)
+++ Zope3/trunk/src/zope/publisher/tests/test_http.py	2005-10-11 20:16:05 UTC (rev 39071)
@@ -62,7 +62,14 @@
 
     def getCacheStreamValue(self):
         self.stream.cacheStream.seek(0)
-        return self.stream.cacheStream.read()
+        result = self.stream.cacheStream.read()
+        # We just did a read on a file opened for update.  If the next
+        # operation on that file is a write, behavior is 100% undefined,
+        # and it in fact frequently (but not always) blows up on Windows.
+        # Behavior is 100% defined instead if we explictly seek.  Since
+        # we expect to be at EOF now, explicitly seek to the end.
+        self.stream.cacheStream.seek(0, 2)
+        return result
 
     def testRead(self):
         output = ''



More information about the Zope3-Checkins mailing list