]> granicus.if.org Git - python/commit
Fix the ctypes tests. Patch from Victor Stinner. He writes:
authorThomas Heller <theller@ctypes.org>
Wed, 8 Aug 2007 18:47:32 +0000 (18:47 +0000)
committerThomas Heller <theller@ctypes.org>
Wed, 8 Aug 2007 18:47:32 +0000 (18:47 +0000)
commit2fb5ac745bf2edd03261ca8144eb73a1f6e54af3
tree411516f988845a5cc4a25c97262dcdab7f1171e4
parentdf5f6b551ad89257a579682114ae9f2ab1d3755e
Fix the ctypes tests.  Patch from Victor Stinner.  He writes:

The problem is that ctypes c_char (and c_char_p) creates unicode string
instead of byte string. I attached a proposition (patch) to change this
behaviour (use bytes for c_char).

So in next example, it will display 'bytes' and not 'str':
  from ctypes import c_buffer, c_char
  buf = c_buffer("abcdef")
  print (type(buf[0]))

Other behaviour changes:
 - repr(c_char) adds a "b"
   eg. repr(c_char('x')) is "c_char(b'x')" instead of "c_char('x')"
 - bytes is mutable whereas str is not:
   this may break some modules based on ctypes
Lib/ctypes/test/test_arrays.py
Lib/ctypes/test/test_buffers.py
Lib/ctypes/test/test_callbacks.py
Lib/ctypes/test/test_numbers.py
Lib/ctypes/test/test_repr.py
Lib/ctypes/test/test_stringptr.py
Modules/_ctypes/cfield.c