Author: Armin Rigo <[email protected]>
Branch:
Changeset: r56018:ce6dc9187eff
Date: 2012-07-10 20:22 +0200
http://bitbucket.org/pypy/pypy/changeset/ce6dc9187eff/
Log: Backed out changeset 40051e63af13
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
@@ -4,9 +4,8 @@
store_reference, ensure_objects, CArgObject
import inspect
-def names_and_fields(self, superclass, anonymous_fields=None):
+def names_and_fields(self, _fields_, superclass, anonymous_fields=None):
# _fields_: list of (name, ctype, [optional_bitfield])
- _fields_ = self._fields_
if isinstance(_fields_, tuple):
_fields_ = list(_fields_)
for f in _fields_:
@@ -132,11 +131,11 @@
raise AttributeError("_fields_ is final")
if self in [f[1] for f in value]:
raise AttributeError("Structure or union cannot contain itself")
- _CDataMeta.__setattr__(self, '_fields_', value)
names_and_fields(
self,
- self.__bases__[0],
+ value, self.__bases__[0],
self.__dict__.get('_anonymous_', None))
+ _CDataMeta.__setattr__(self, '_fields_', value)
return
_CDataMeta.__setattr__(self, name, value)
@@ -155,10 +154,9 @@
for item in typedict.get('_anonymous_', []):
if item not in dict(typedict['_fields_']):
raise AttributeError("Anonymous field not found")
- setattr(res, '_fields_', typedict['_fields_'])
names_and_fields(
res,
- cls[0],
+ typedict['_fields_'], cls[0],
typedict.get('_anonymous_', None))
return res
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
@@ -433,15 +433,6 @@
obj = X()
assert isinstance(obj.items, Array)
- def test_big_endian(self):
- py.test.skip("xxx: reversed-endian support")
- class S(BigEndianStructure):
- _fields_ = [('x', c_short)]
- obj = S()
- obj.x = 0x1234
- assert cast(pointer(obj), POINTER(c_ubyte))[0] == 0x12
- assert cast(pointer(obj), POINTER(c_ubyte))[1] == 0x34
-
class TestPointerMember(BaseCTypesTestChecker):
def test_1(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit