Author: David Schneider <david.schnei...@picle.org> Branch: Changeset: r64941:b4cd93e60f86 Date: 2013-06-19 13:11 -0500 http://bitbucket.org/pypy/pypy/changeset/b4cd93e60f86/
Log: merge heads diff --git a/pypy/module/_cffi_backend/ctypeenum.py b/pypy/module/_cffi_backend/ctypeenum.py --- a/pypy/module/_cffi_backend/ctypeenum.py +++ b/pypy/module/_cffi_backend/ctypeenum.py @@ -13,7 +13,6 @@ _mixin_ = True def __init__(self, space, name, size, align, enumerators, enumvalues): - name = "enum " + name self._super.__init__(self, space, size, name, len(name), align) self.enumerators2values = {} # str -> int self.enumvalues2erators = {} # int -> str diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py --- a/pypy/module/_cffi_backend/ctypeptr.py +++ b/pypy/module/_cffi_backend/ctypeptr.py @@ -185,7 +185,7 @@ else: extra = " *" self.is_file = (ctitem.name == "struct _IO_FILE" or - ctitem.name == "struct $FILE") + ctitem.name == "FILE") self.is_void_ptr = isinstance(ctitem, ctypevoid.W_CTypeVoid) W_CTypePtrBase.__init__(self, space, size, extra, 2, ctitem) diff --git a/pypy/module/_cffi_backend/ctypestruct.py b/pypy/module/_cffi_backend/ctypestruct.py --- a/pypy/module/_cffi_backend/ctypestruct.py +++ b/pypy/module/_cffi_backend/ctypestruct.py @@ -25,7 +25,6 @@ custom_field_pos = False def __init__(self, space, name): - name = '%s %s' % (self.kind, name) W_CType.__init__(self, space, -1, name, len(name)) def check_complete(self, w_errorcls=None): diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -641,6 +641,8 @@ def test_new_struct_type(): BStruct = new_struct_type("foo") + assert repr(BStruct) == "<ctype 'foo'>" + BStruct = new_struct_type("struct foo") assert repr(BStruct) == "<ctype 'struct foo'>" BPtr = new_pointer_type(BStruct) assert repr(BPtr) == "<ctype 'struct foo *'>" @@ -648,7 +650,7 @@ py.test.raises(ValueError, alignof, BStruct) def test_new_union_type(): - BUnion = new_union_type("foo") + BUnion = new_union_type("union foo") assert repr(BUnion) == "<ctype 'union foo'>" BPtr = new_pointer_type(BUnion) assert repr(BPtr) == "<ctype 'union foo *'>" @@ -657,7 +659,7 @@ BLong = new_primitive_type("long") BChar = new_primitive_type("char") BShort = new_primitive_type("short") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") assert BStruct.kind == "struct" assert BStruct.cname == "struct foo" assert BStruct.fields is None @@ -689,7 +691,7 @@ def test_complete_union(): BLong = new_primitive_type("long") BChar = new_primitive_type("char") - BUnion = new_union_type("foo") + BUnion = new_union_type("union foo") assert BUnion.kind == "union" assert BUnion.cname == "union foo" assert BUnion.fields is None @@ -708,7 +710,7 @@ def test_struct_instance(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) p = cast(BStructPtr, 0) py.test.raises(AttributeError, "p.a1") # opaque @@ -728,7 +730,7 @@ def test_union_instance(): BInt = new_primitive_type("int") BUInt = new_primitive_type("unsigned int") - BUnion = new_union_type("bar") + BUnion = new_union_type("union bar") complete_struct_or_union(BUnion, [('a1', BInt, -1), ('a2', BUInt, -1)]) p = newp(new_pointer_type(BUnion), [-42]) bigval = -42 + (1 << (8*size_of_int())) @@ -744,7 +746,7 @@ def test_struct_pointer(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BInt, -1), ('a2', BInt, -1)]) @@ -758,7 +760,7 @@ BVoidP = new_pointer_type(new_void_type()) BInt = new_primitive_type("int") BIntPtr = new_pointer_type(BInt) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BInt, -1), ('a2', BInt, -1), @@ -792,7 +794,7 @@ def test_array_in_struct(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BArrayInt5 = new_array_type(new_pointer_type(BInt), 5) complete_struct_or_union(BStruct, [('a1', BArrayInt5, -1)]) s = newp(new_pointer_type(BStruct), [[20, 24, 27, 29, 30]]) @@ -803,7 +805,7 @@ def offsetof(BType, fieldname): return typeoffsetof(BType, fieldname)[1] BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") py.test.raises(TypeError, offsetof, BInt, "abc") py.test.raises(TypeError, offsetof, BStruct, "abc") complete_struct_or_union(BStruct, [('abc', BInt, -1), ('def', BInt, -1)]) @@ -832,7 +834,7 @@ def test_function_type_taking_struct(): BChar = new_primitive_type("char") BShort = new_primitive_type("short") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a1', BChar, -1), ('a2', BShort, -1)]) BFunc = new_function_type((BStruct,), BShort, False) @@ -937,7 +939,7 @@ def test_call_function_7(): BChar = new_primitive_type("char") BShort = new_primitive_type("short") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BChar, -1), ('a2', BShort, -1)]) @@ -953,7 +955,7 @@ def test_call_function_20(): BChar = new_primitive_type("char") BShort = new_primitive_type("short") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BChar, -1), ('a2', BShort, -1)]) @@ -965,7 +967,7 @@ def test_call_function_21(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a', BInt, -1), ('b', BInt, -1), ('c', BInt, -1), @@ -985,7 +987,7 @@ def test_call_function_22(): BInt = new_primitive_type("int") BArray10 = new_array_type(new_pointer_type(BInt), 10) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructP = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a', BArray10, -1)]) BFunc22 = new_function_type((BStruct, BStruct), BStruct, False) @@ -1023,7 +1025,7 @@ def test_cannot_pass_struct_with_array_of_length_0(): BInt = new_primitive_type("int") BArray0 = new_array_type(new_pointer_type(BInt), 0) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a', BArray0)]) py.test.raises(NotImplementedError, new_function_type, (BStruct,), BInt, False) @@ -1048,7 +1050,7 @@ def test_cannot_call_with_a_autocompleted_struct(): BSChar = new_primitive_type("signed char") BDouble = new_primitive_type("double") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('c', BDouble, -1, 8), ('a', BSChar, -1, 2), @@ -1221,7 +1223,7 @@ BSChar = new_primitive_type("signed char") BInt = new_primitive_type("int") BDouble = new_primitive_type("double") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a', BSChar, -1), ('b', BDouble, -1)]) @@ -1238,7 +1240,7 @@ def test_callback_returning_big_struct(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a', BInt, -1), ('b', BInt, -1), @@ -1275,26 +1277,27 @@ def test_enum_type(): BUInt = new_primitive_type("unsigned int") BEnum = new_enum_type("foo", (), (), BUInt) - assert repr(BEnum) == "<ctype 'enum foo'>" + assert repr(BEnum) == "<ctype 'foo'>" assert BEnum.kind == "enum" - assert BEnum.cname == "enum foo" + assert BEnum.cname == "foo" assert BEnum.elements == {} # BInt = new_primitive_type("int") - BEnum = new_enum_type("foo", ('def', 'c', 'ab'), (0, 1, -20), BInt) + BEnum = new_enum_type("enum foo", ('def', 'c', 'ab'), (0, 1, -20), BInt) assert BEnum.kind == "enum" + assert BEnum.cname == "enum foo" assert BEnum.elements == {-20: 'ab', 0: 'def', 1: 'c'} # 'elements' is not the real dict, but merely a copy BEnum.elements[2] = '??' assert BEnum.elements == {-20: 'ab', 0: 'def', 1: 'c'} # - BEnum = new_enum_type("bar", ('ab', 'cd'), (5, 5), BUInt) + BEnum = new_enum_type("enum bar", ('ab', 'cd'), (5, 5), BUInt) assert BEnum.elements == {5: 'ab'} assert BEnum.relements == {'ab': 5, 'cd': 5} def test_cast_to_enum(): BInt = new_primitive_type("int") - BEnum = new_enum_type("foo", ('def', 'c', 'ab'), (0, 1, -20), BInt) + BEnum = new_enum_type("enum foo", ('def', 'c', 'ab'), (0, 1, -20), BInt) assert sizeof(BEnum) == sizeof(BInt) e = cast(BEnum, 0) assert repr(e) == "<cdata 'enum foo' 0: def>" @@ -1308,27 +1311,27 @@ assert string(cast(BEnum, -242 + 2**128)) == '-242' # BUInt = new_primitive_type("unsigned int") - BEnum = new_enum_type("bar", ('def', 'c', 'ab'), (0, 1, 20), BUInt) + BEnum = new_enum_type("enum bar", ('def', 'c', 'ab'), (0, 1, 20), BUInt) e = cast(BEnum, -1) assert repr(e) == "<cdata 'enum bar' 4294967295>" # unsigned int # BLong = new_primitive_type("long") - BEnum = new_enum_type("baz", (), (), BLong) + BEnum = new_enum_type("enum baz", (), (), BLong) assert sizeof(BEnum) == sizeof(BLong) e = cast(BEnum, -1) assert repr(e) == "<cdata 'enum baz' -1>" def test_enum_with_non_injective_mapping(): BInt = new_primitive_type("int") - BEnum = new_enum_type("foo", ('ab', 'cd'), (7, 7), BInt) + BEnum = new_enum_type("enum foo", ('ab', 'cd'), (7, 7), BInt) e = cast(BEnum, 7) assert repr(e) == "<cdata 'enum foo' 7: ab>" assert string(e) == 'ab' def test_enum_in_struct(): BInt = new_primitive_type("int") - BEnum = new_enum_type("foo", ('def', 'c', 'ab'), (0, 1, -20), BInt) - BStruct = new_struct_type("bar") + BEnum = new_enum_type("enum foo", ('def', 'c', 'ab'), (0, 1, -20), BInt) + BStruct = new_struct_type("struct bar") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BEnum, -1)]) p = newp(BStructPtr, [-20]) @@ -1432,7 +1435,7 @@ def test_struct_with_bitfields(): BLong = new_primitive_type("long") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") LONGBITS = 8 * sizeof(BLong) complete_struct_or_union(BStruct, [('a1', BLong, 1), ('a2', BLong, 2), @@ -1455,7 +1458,7 @@ def test_bitfield_instance(): BInt = new_primitive_type("int") BUnsignedInt = new_primitive_type("unsigned int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a1', BInt, 1), ('a2', BUnsignedInt, 2), ('a3', BInt, 3)]) @@ -1485,14 +1488,14 @@ def test_bitfield_instance_init(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a1', BInt, 1)]) p = newp(new_pointer_type(BStruct), [-1]) assert p.a1 == -1 p = newp(new_pointer_type(BStruct), {'a1': -1}) assert p.a1 == -1 # - BUnion = new_union_type("bar") + BUnion = new_union_type("union bar") complete_struct_or_union(BUnion, [('a1', BInt, 1)]) p = newp(new_pointer_type(BUnion), [-1]) assert p.a1 == -1 @@ -1561,7 +1564,7 @@ py.test.raises(IndexError, newp, BArray, tuple(b'123456')) py.test.raises(IndexError, newp, BArray, list(b'123456')) py.test.raises(IndexError, newp, BArray, b'123456') - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, []) py.test.raises(TypeError, newp, new_pointer_type(BStruct), b'') py.test.raises(ValueError, newp, new_pointer_type(BStruct), [b'1']) @@ -1601,7 +1604,7 @@ p = newp(new_pointer_type(BFloat), cast(BFloat, 12.25)) assert p[0] == 12.25 # - BStruct = new_struct_type("foo_s") + BStruct = new_struct_type("struct foo_s") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BInt, -1)]) s1 = newp(BStructPtr, [42]) @@ -1619,7 +1622,7 @@ s2 = newp(BStructPtr, s1[0]) assert s2.a1 == 42 # - BUnion = new_union_type("foo_u") + BUnion = new_union_type("union foo_u") BUnionPtr = new_pointer_type(BUnion) complete_struct_or_union(BUnion, [('a1', BInt, -1)]) u1 = newp(BUnionPtr, [42]) @@ -1697,7 +1700,7 @@ BChar = new_primitive_type("char") BCharP = new_pointer_type(BChar) BCharArray10 = new_array_type(BCharP, 10) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BCharArray10, -1)]) p = newp(BStructPtr, None) @@ -1714,7 +1717,7 @@ new_function_type((), BFunc) # works new_function_type((), new_primitive_type("int")) new_function_type((), new_pointer_type(BFunc)) - BUnion = new_union_type("foo_u") + BUnion = new_union_type("union foo_u") complete_struct_or_union(BUnion, []) py.test.raises(NotImplementedError, new_function_type, (), BUnion) py.test.raises(TypeError, new_function_type, (), BArray) @@ -1725,7 +1728,7 @@ BFloat = new_primitive_type("float") BDouble = new_primitive_type("double") BInt = new_primitive_type("int") - BStruct = new_struct_type("foo_s") + BStruct = new_struct_type("struct foo_s") complete_struct_or_union(BStruct, [('a1', BChar, -1), ('a2', BShort, -1)]) BFunc10 = new_function_type((BInt,), BStruct) @@ -1735,7 +1738,7 @@ assert s.a1 == bytechr(40) assert s.a2 == 40 * 40 # - BStruct11 = new_struct_type("test11") + BStruct11 = new_struct_type("struct test11") complete_struct_or_union(BStruct11, [('a1', BInt, -1), ('a2', BInt, -1)]) BFunc11 = new_function_type((BInt,), BStruct11) @@ -1745,7 +1748,7 @@ assert s.a1 == 40 assert s.a2 == 40 * 40 # - BStruct12 = new_struct_type("test12") + BStruct12 = new_struct_type("struct test12") complete_struct_or_union(BStruct12, [('a1', BDouble, -1), ]) BFunc12 = new_function_type((BInt,), BStruct12) @@ -1754,7 +1757,7 @@ assert repr(s) == "<cdata 'struct test12' owning 8 bytes>" assert s.a1 == 40.0 # - BStruct13 = new_struct_type("test13") + BStruct13 = new_struct_type("struct test13") complete_struct_or_union(BStruct13, [('a1', BInt, -1), ('a2', BInt, -1), ('a3', BInt, -1)]) @@ -1766,7 +1769,7 @@ assert s.a2 == 40 * 40 assert s.a3 == 40 * 40 * 40 # - BStruct14 = new_struct_type("test14") + BStruct14 = new_struct_type("struct test14") complete_struct_or_union(BStruct14, [('a1', BFloat, -1), ]) BFunc14 = new_function_type((BInt,), BStruct14) @@ -1775,7 +1778,7 @@ assert repr(s) == "<cdata 'struct test14' owning 4 bytes>" assert s.a1 == 40.0 # - BStruct15 = new_struct_type("test15") + BStruct15 = new_struct_type("struct test15") complete_struct_or_union(BStruct15, [('a1', BFloat, -1), ('a2', BInt, -1)]) BFunc15 = new_function_type((BInt,), BStruct15) @@ -1785,7 +1788,7 @@ assert s.a1 == 40.0 assert s.a2 == 40 * 40 # - BStruct16 = new_struct_type("test16") + BStruct16 = new_struct_type("struct test16") complete_struct_or_union(BStruct16, [('a1', BFloat, -1), ('a2', BFloat, -1)]) BFunc16 = new_function_type((BInt,), BStruct16) @@ -1795,7 +1798,7 @@ assert s.a1 == 40.0 assert s.a2 == -40.0 # - BStruct17 = new_struct_type("test17") + BStruct17 = new_struct_type("struct test17") complete_struct_or_union(BStruct17, [('a1', BInt, -1), ('a2', BFloat, -1)]) BFunc17 = new_function_type((BInt,), BStruct17) @@ -1818,7 +1821,7 @@ BFunc2 = new_function_type((), new_primitive_type("short")) BCharP = new_pointer_type(new_primitive_type("char")) BIntP = new_pointer_type(new_primitive_type("int")) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BFunc, -1)]) newp(BStructPtr, [cast(BFunc, 0)]) @@ -1845,7 +1848,7 @@ assert not pyuni4 # BWCharP = new_pointer_type(BWChar) - BStruct = new_struct_type("foo_s") + BStruct = new_struct_type("struct foo_s") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BWChar, -1), ('a2', BWCharP, -1)]) @@ -1957,7 +1960,7 @@ # exception to the no-keepalive rule: p=newp(BStructPtr) returns a # pointer owning the memory, and p[0] returns a pointer to the # struct that *also* owns the memory - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', new_primitive_type("int"), -1), ('a2', new_primitive_type("int"), -1), @@ -1977,7 +1980,7 @@ assert q.a1 == 123456 def test_nokeepalive_struct(): - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) BStructPtrPtr = new_pointer_type(BStructPtr) complete_struct_or_union(BStruct, [('a1', new_primitive_type("int"), -1)]) @@ -2164,7 +2167,7 @@ assert repr(x) == "<cdata 'int[3]' NULL>" def test_cast_invalid(): - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, []) p = cast(new_pointer_type(BStruct), 123456) s = p[0] @@ -2183,7 +2186,7 @@ def test_bug_delattr(): BLong = new_primitive_type("long") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a1', BLong, -1)]) x = newp(new_pointer_type(BStruct)) py.test.raises(AttributeError, "del x.a1") @@ -2192,7 +2195,7 @@ py.test.skip("later") BLong = new_primitive_type("long") BArray = new_array_type(new_pointer_type(BLong), None) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructP = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BLong, -1), ('a2', BArray, -1)]) @@ -2308,7 +2311,7 @@ BLong = new_primitive_type("long") BLongP = new_pointer_type(BLong) BArray0 = new_array_type(BLongP, length) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BArray0, -1)]) p = newp(BStructPtr, None) @@ -2320,8 +2323,8 @@ def test_nested_anonymous_struct(): BInt = new_primitive_type("int") BChar = new_primitive_type("char") - BStruct = new_struct_type("foo") - BInnerStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") + BInnerStruct = new_struct_type("struct foo") complete_struct_or_union(BInnerStruct, [('a1', BInt, -1), ('a2', BChar, -1)]) complete_struct_or_union(BStruct, [('', BInnerStruct, -1), @@ -2353,12 +2356,12 @@ BChar = new_primitive_type("char") BShort = new_primitive_type("short") assert sizeof(BShort) == alignof(BShort) == 2 - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a1', BChar), ('a2', BChar), ('a3', BChar)]) assert sizeof(BStruct) == 3 and alignof(BStruct) == 1 - BUnion = new_union_type("u") + BUnion = new_union_type("union u") complete_struct_or_union(BUnion, [('s', BStruct), ('i', BShort)]) assert sizeof(BUnion) == 4 @@ -2366,7 +2369,7 @@ def test_unaligned_struct(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('b', BInt, -1, 1)], None, 5, 1) @@ -2424,7 +2427,7 @@ def test_typeoffsetof(): BChar = new_primitive_type("char") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BChar, -1), ('a2', BChar, -1), @@ -2440,14 +2443,14 @@ def test_typeoffsetof_no_bitfield(): BInt = new_primitive_type("int") - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") complete_struct_or_union(BStruct, [('a1', BInt, 4)]) py.test.raises(TypeError, typeoffsetof, BStruct, 'a1') def test_rawaddressof(): BChar = new_primitive_type("char") BCharP = new_pointer_type(BChar) - BStruct = new_struct_type("foo") + BStruct = new_struct_type("struct foo") BStructPtr = new_pointer_type(BStruct) complete_struct_or_union(BStruct, [('a1', BChar, -1), ('a2', BChar, -1), @@ -2508,7 +2511,7 @@ if sys.platform == "win32": py.test.skip("testing FILE not implemented") # - BFILE = new_struct_type("_IO_FILE") + BFILE = new_struct_type("struct _IO_FILE") BFILEP = new_pointer_type(BFILE) BChar = new_primitive_type("char") BCharP = new_pointer_type(BChar) @@ -2540,7 +2543,7 @@ if sys.platform == "win32": py.test.skip("testing FILE not implemented") # - B_NOT_FILE = new_struct_type("NOT_FILE") + B_NOT_FILE = new_struct_type("struct NOT_FILE") B_NOT_FILEP = new_pointer_type(B_NOT_FILE) BChar = new_primitive_type("char") BCharP = new_pointer_type(BChar) @@ -2563,7 +2566,7 @@ if sys.platform == "win32": py.test.skip("testing FILE not implemented") # - BFILE = new_struct_type("$FILE") + BFILE = new_struct_type("FILE") BFILEP = new_pointer_type(BFILE) BChar = new_primitive_type("char") BCharP = new_pointer_type(BChar) @@ -2762,7 +2765,7 @@ BShort = new_primitive_type("short") BInt = new_primitive_type("int") BUInt = new_primitive_type("unsigned int") - BStruct = new_struct_type("foo1") + BStruct = new_struct_type("struct foo1") complete_struct_or_union(BStruct, [('a', BChar, -1), ('b1', BInt, 9), ('b2', BUInt, 7), @@ -2775,7 +2778,7 @@ assert sizeof(BStruct) == 12 assert alignof(BStruct) == 4 # - BStruct = new_struct_type("foo2") + BStruct = new_struct_type("struct foo2") complete_struct_or_union(BStruct, [('a', BChar, -1), ('', BShort, 9), ('c', BChar, -1)], -1, -1, -1, flag) @@ -2790,7 +2793,7 @@ assert sizeof(BStruct) == 6 assert alignof(BStruct) == 2 # - BStruct = new_struct_type("foo2") + BStruct = new_struct_type("struct foo2") complete_struct_or_union(BStruct, [('a', BChar, -1), ('', BInt, 0), ('', BInt, 0), diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1222,8 +1222,7 @@ def _safe_find(self, w_list, obj, start, stop): l = self.unerase(w_list.lstorage) for i in range(start, min(stop, len(l))): - val = l[i] - if val == obj: + if l[i] == obj: return i raise ValueError @@ -1543,6 +1542,18 @@ if reverse: l.reverse() + def _safe_find(self, w_list, obj, start, stop): + from rpython.rlib.rfloat import isnan + if not isnan(obj): + return AbstractUnwrappedStrategy._safe_find(self, w_list, obj, + start, stop) + # unwrapped nan != nan, finding it requires more effort + l = self.unerase(w_list.lstorage) + for i in range(start, min(stop, len(l))): + if isnan(l[i]): + return i + raise ValueError + class StringListStrategy(AbstractUnwrappedStrategy, ListStrategy): _none_value = None diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py --- a/pypy/objspace/std/test/test_listobject.py +++ b/pypy/objspace/std/test/test_listobject.py @@ -1314,6 +1314,10 @@ non_list = NonList() assert [] != non_list + def test_nan_containment(self): + nan = float('nan') + assert nan in [nan] + class AppTestForRangeLists(AppTestW_ListObject): spaceconfig = {"objspace.std.withrangelist": True} _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit