New issue 2877: Nested ctypes array instance does not support indexing
operation properly
https://bitbucket.org/pypy/pypy/issues/2877/nested-ctypes-array-instance-does-not
Sheng Zou:
Setup code snippet:
from ctypes import *
class HostRxDataBuffer(Array):
_length_ = 100
_type_ = c_char
class HostRxDataBufferArray(Array):
_length_ = 8
_type_ = HostRxDataBuffer
Result in PyPy:
/Users/local/Downloads/pypy2-v6.0.0-osx64/bin/pypy
Python 2.7.13 (ab0b9caf307d, Apr 24 2018, 18:05:02)
[PyPy 6.0.0 with GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on
darwin
>>>> x = HostRxDataBuffer()
>>>> x[0]
'\x00'
This is correct. However the following does not make sense:
>>>> y = HostRxDataBufferArray()
>>>> y[0]
''
This is incorrect. y[0] should be an instance of HostRxDataBuffer
Compared to result in CPython:
python
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
>>> x = HostRxDataBuffer()
>>> x[0]
'\x00'
The result is identical to PyPy.
>>> y = HostRxDataBufferArray()
>>> y[0]
<__main__.HostRxDataBuffer object at 0x1010db7a0>
The result is different from PyPy and the result from CPython makes perfect
sense.
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue