summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/memoryview_itemsize.py
blob: 5428a41785f8d70b03b7b4637eaf2008c00e2f98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
try:
    memoryview(b'a').itemsize
except:
    print("SKIP")
    raise SystemExit
try:
    from array import array
except ImportError:
    print("SKIP")
    raise SystemExit

for code in ['b', 'h', 'i', 'q', 'f', 'd']:
    print(memoryview(array(code)).itemsize)

# 'l' varies depending on word size of the machine
print(memoryview(array('l')).itemsize in (4, 8))

# shouldn't be able to store to the itemsize attribute
try:
    memoryview(b'a').itemsize = 1
except AttributeError:
    print('AttributeError')