[Python-3000-checkins] r56313 - python/branches/py3k-struni/Lib/ctypes/test/test_objects.py

Guido van Rossum guido at python.org
Thu Jul 12 14:44:53 CEST 2007


On 7/12/07, thomas.heller <python-3000-checkins at python.org> wrote:
> Author: thomas.heller
> Date: Thu Jul 12 13:59:52 2007
> New Revision: 56313
>
> Modified:
>    python/branches/py3k-struni/Lib/ctypes/test/test_objects.py
> Log:
> Fix a ctypes test.
>
> Modified: python/branches/py3k-struni/Lib/ctypes/test/test_objects.py
> ==============================================================================
> --- python/branches/py3k-struni/Lib/ctypes/test/test_objects.py (original)
> +++ python/branches/py3k-struni/Lib/ctypes/test/test_objects.py Thu Jul 12 13:59:52 2007
> @@ -22,9 +22,9 @@
>
>  >>> array[4] = 'foo bar'
>  >>> array._objects
> -{'4': 'foo bar'}
> +{s'4': b'foo bar'}
>  >>> array[4]
> -'foo bar'
> +s'foo bar'
>  >>>

FWIW, when tests show s'...', the preferred fix is to change the
underlying code to return unicode, not to fix the test to accept the
8-bit string. This is why we made str8.__repr__ add the 's' prefix: so
more tests would fail so we'd be alerted to places still returning
str8 instead of str.

>
>  It gets more complicated when the ctypes instance itself is contained
> @@ -47,9 +47,9 @@
>
>  >>> x.array[0] = 'spam spam spam'
>  >>> x._objects
> -{'0:2': 'spam spam spam'}
> +{s'0:2': b'spam spam spam'}
>  >>> x.array._b_base_._objects
> -{'0:2': 'spam spam spam'}
> +{s'0:2': b'spam spam spam'}
>  >>>
>
>  '''

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000-checkins mailing list