[Zope3-dev] Zope3 trunk degenerating on Windows

Tim Peters tim.peters at gmail.com
Tue Oct 11 15:49:04 EDT 2005


[Michael Kerrin]
> I have just changed the svn:external for Twisted to a more stable 2.1 branch
> which should contain the fix for the Windows problem you reported. I still
> haven't checked Zope on windows yet because of a problem in the with FTP but
> I have being assured that it will run.
>
> I will check the buildbot link you sent in the morning and see what the status
> is then, fingers crossed.

The buildbot already reported successful test runs on Linux.  The
buildbot Windows machine is still useless (still dying in its svn
step).

The unit tests on my Windows box are now down to three related errors:

Error in test testRead (zope.publisher.tests.test_http.HTTPInputStreamTests)
Traceback (most recent call last):
  File "C:\Python24\lib\unittest.py", line 260, in run
    testMethod()
  File "C:\Code\Zope3\src\zope\publisher\tests\test_http.py", line 72,
in testRead
    output += self.stream.read()
  File "C:\Code\Zope3\src\zope\publisher\http.py", line 192, in read
    self.cacheStream.write(data)
IOError: (0, 'Error')


Error in test testReadLine (zope.publisher.tests.test_http.HTTPInputStreamTests)
Traceback (most recent call last):
  File "C:\Python24\lib\unittest.py", line 260, in run
    testMethod()
  File "C:\Code\Zope3\src\zope\publisher\tests\test_http.py", line 79,
in testReadLine
    output += self.stream.readline()
  File "C:\Code\Zope3\src\zope\publisher\http.py", line 197, in readline
    self.cacheStream.write(data)
IOError: (0, 'Error')


Error in test testReadLines
(zope.publisher.tests.test_http.HTTPInputStreamTests)
Traceback (most recent call last):
  File "C:\Python24\lib\unittest.py", line 260, in run
    testMethod()
  File "C:\Code\Zope3\src\zope\publisher\tests\test_http.py", line 90,
in testReadLines
    output += ''.join(self.stream.readlines())
  File "C:\Code\Zope3\src\zope\publisher\http.py", line 202, in readlines
    self.cacheStream.write(''.join(data))
IOError: (0, 'Error')

I believe these are errors in Zope3 unrelated to Twisted (although the
broken code was checked in as part of "Merged the zope3-twisted-merge
branch 38950:38964").  This is testRead() and the function before it:

    def getCacheStreamValue(self):
        self.stream.cacheStream.seek(0)
        return self.stream.cacheStream.read()

    def testRead(self):
        output = ''
        self.assertEqual(output, self.getCacheStreamValue())
        output += self.stream.read(5)
        self.assertEqual(output, self.getCacheStreamValue())
        output += self.stream.read()
        self.assertEqual(output, self.getCacheStreamValue())
        self.assertEqual(data, self.getCacheStreamValue())

So the first assertEqual(), as a side effect, seeks to position 0 in
cacheStream then reads the whole thing.  That part of the test passes.
 Next it tries doing

    self.stream.read(5)

But the implementation of stream.read is here:

    def read(self, size=-1):
        data = self.stream.read(size)
        self.cacheStream.write(data)
        return data

and, as a side effect, that _writes_ to cacheStream.  This is an
illegal sequence of operations:  in a file opened for update, all
behavior is undefined if a read is followed by a write (or vice versa)
without an intervening file-positioning operation (typically a
seek()).

The Windows implementation of C stdio happens to blow up in this case.
 That's fine by the C standard.  It's also fine by the standard if it
always returned an empty string, or the King James Bible, or wiped
Linux from the machine and silently upgraded you to Windows <wink>.  I
think I know how to fix it, so enough for now.


More information about the Zope3-dev mailing list