[pypy-issue] [issue1270] ctypes structure should allow unicode field names

Antony Lee tracker at bugs.pypy.org
Fri Sep 28 01:58:23 CEST 2012


New submission from Antony Lee <anntzer.lee at gmail.com>:

from ctypes import *
class C(Structure): _fields_ = [(u"field", c_int)]

fails with pypy (TypeError: cannot add non-string keys to dict of a type), but
works with cpython2.  The bug is in structure.py, line 71:

self.__dict__.update(fields)

which should be replaced by

for k, v in fields: setattr(self, k, v)

because setattr does (I think?) an implicit unicode->bytes conversion.

----------
messages: 4786
nosy: antony, pypy-issue
priority: bug
status: unread
title: ctypes structure should allow unicode field names

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1270>
________________________________________


More information about the pypy-issue mailing list