Message190487
I came upon this too. In Python 2 it used to expect a one character string. Apparently the same error message has been carried forward to Python 3 too, though now the actual expected input is either a one character bytes type and not a str type, or an int corresponding to the ord() value of that char.
Minimal demonstration:
$ python
Python 2.7.4 (default, Apr 19 2013, 18:28:01)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> class test ( Structure ) :
... _fields_ = [ ( "ch", c_char ) ]
...
>>> a = test()
>>> a.ch = ord('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: one character string expected
>>> a.ch = 'c'
>>> a.ch
'c'
>>>
$ python3
Python 3.3.1 (default, Apr 17 2013, 22:30:32)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> class test ( Structure ) :
... _fields_ = [ ( "ch", c_char ) ]
...
>>> a = test()
>>> a.ch = 'c'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: one character string expected
>>> a.ch = b'c'
>>> a.ch
b'c'
>>> a.ch = ord('c')
>>> a.ch
b'c'
>>> |
|
Date |
User |
Action |
Args |
2013-06-02 14:10:55 | jamadagni | set | recipients:
+ jamadagni, amaury.forgeotdarc, meador.inge, Steven.Barker |
2013-06-02 14:10:55 | jamadagni | set | messageid: <1370182255.52.0.890953198333.issue17991@psf.upfronthosting.co.za> |
2013-06-02 14:10:55 | jamadagni | link | issue17991 messages |
2013-06-02 14:10:55 | jamadagni | create | |
|