Author: arigo <[email protected]>
Branch: 
Changeset: r58205:98a9f4ed53bb
Date: 2012-10-18 11:30 +0200
http://bitbucket.org/pypy/pypy/changeset/98a9f4ed53bb/

Log:    Merged in anntzer/pypy (pull request #89)

diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -69,7 +69,8 @@
                 resnames.append(name)
         names = resnames
     self._names = names
-    self.__dict__.update(fields)
+    for name, field in fields.items():
+        setattr(self, name, field)
 
 class Field(object):
     def __init__(self, name, offset, size, ctype, num, is_bitfield):
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py 
b/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py
@@ -441,6 +441,11 @@
         p = pointer(obj)
         assert p.contents._b_base_ is p
 
+    def test_unicode_field_name(self):
+        # setattr autoconverts field names to bytes
+        class X(Structure):
+            _fields_ = [(u"i", c_int)]
+
 class TestPointerMember(BaseCTypesTestChecker):
 
     def test_1(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to