Commit 98487311 authored by Mark Florisson's avatar Mark Florisson

Fix builtins.memoryview affected tests in Py3.3

parent 2306b721
......@@ -1439,7 +1439,7 @@ cdef format_from_typeinfo(__Pyx_TypeInfo *type):
while field.type:
part = format_from_typeinfo(field.type).decode('ascii')
parts.append('%s:%s:' % (part, field.name))
parts.append('%s:%s:' % (part, (<char *> field.name).decode('ascii')))
field += 1
result = alignment.join(parts) + '}'
......
......@@ -12,13 +12,17 @@ b'abcdefg'
>>> m1 = memoryview(b1)
__getbuffer__ called
>>> m1.tobytes()
Semantics changed in python 3.3
>> m1.tobytes()
__getbuffer__ called
b'abcdefg'
>>> m2 = memoryview(b2)
__getbuffer__ called
>>> m2.tobytes()
Semantics changed in python 3.3
>> m2.tobytes()
__getbuffer__ called
releasing!
b'abcdefg'
......
......@@ -13,6 +13,12 @@ import gc
import sys
import re
if sys.version_info[0] < 3:
import __builtin__ as builtins
else:
import builtins
__test__ = {}
def testcase(func):
......@@ -1650,12 +1656,7 @@ cdef test_structs_with_arr(FusedStruct array[10]):
for j in range(3):
myslice1[i].chars[j] = 97 + j
if sys.version_info[:2] >= (2, 7):
if sys.version_info[0] < 3:
import __builtin__ as builtins
else:
import builtins
if sys.version_info[:2] >= (2, 7) and sys.version_info[:2] < (3, 3):
size1 = sizeof(FusedStruct)
size2 = len(builtins.memoryview(myslice1)[0])
assert size1 == size2, (size1, size2, builtins.memoryview(myslice1).format)
......@@ -1675,6 +1676,25 @@ cdef test_structs_with_arr(FusedStruct array[10]):
print myslice1[0].chars[:3].decode('ascii')
cdef struct TestAttrs:
int int_attrib
char char_attrib
@testcase
def test_struct_attributes_format():
"""
>>> test_struct_attributes_format()
T{i:int_attrib:b:char_attrib:}
"""
cdef TestAttrs[10] array
cdef TestAttrs[:] struct_memview = array
if sys.version_info[:2] >= (2, 7):
print builtins.memoryview(struct_memview).format
else:
print "T{i:int_attrib:b:char_attrib:}"
# Test padding at the end of structs in the buffer support
cdef struct PaddedAtEnd:
int a[3]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment