[Python-3000-checkins] r55220 - python/branches/py3k-struni/Lib/test/test_codecs.py

Walter Dörwald walter at livinglogic.de
Thu May 10 08:10:34 CEST 2007


guido.van.rossum wrote:
> Author: guido.van.rossum
> Date: Thu May 10 01:47:07 2007
> New Revision: 55220
> 
> Modified:
>    python/branches/py3k-struni/Lib/test/test_codecs.py
> Log:
> Don't insist on cStringIO.
> 
> 
> Modified: python/branches/py3k-struni/Lib/test/test_codecs.py
> ==============================================================================
> --- python/branches/py3k-struni/Lib/test/test_codecs.py	(original)
> +++ python/branches/py3k-struni/Lib/test/test_codecs.py	Thu May 10 01:47:07 2007
> @@ -1,7 +1,8 @@
>  from test import test_support
>  import unittest
>  import codecs
> -import sys, cStringIO, _testcapi
> +import sys, _testcapi
> +from StringIO import StringIO

This breaks a bunch of tests. Failures look like this:

Traceback (most recent call last):
   File "Lib/test/test_codecs.py", line 1340, in test_streamreaderwriter
     self.assertEquals(srw.read(), "\xfc")
   File "/var/home/walter/checkouts/Python/py3k-struni/Lib/codecs.py", 
line 662, in read
     return self.reader.read(size)
   File "/var/home/walter/checkouts/Python/py3k-struni/Lib/codecs.py", 
line 465, in read
     data = self.bytebuffer + newdata
TypeError: can't concat bytes to str

The problem is that StringIO.StringIO does:

     if not isinstance(buf, basestring):
         buf = str(buf)

which turns bytes into unicode string.

> [...]

Servus,
    Walter


More information about the Python-3000-checkins mailing list