New issue 2878: ctypes array instance does not support assignment operation of 
its element created by method "from_buffer"
https://bitbucket.org/pypy/pypy/issues/2878/ctypes-array-instance-does-not-support

Sheng Zou:

Code snippet:

```
#!python

>>>> from ctypes import *
>>>> class SomeArray(Array):
....     _type_ = c_uint16
....     _size_ = 32
>>>> x = SomeArray()
>>>> x[0] = 1 # This is OK
>>>> x[0] = c_uint16(1) # This is OK
>>>> x[0] = c_uint16.from_buffer(bytearray("\x01\x00")) # Not OK, see error 
>>>> below
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/Users/local/Downloads/pypy-c-jit-95034-d2dd59afa85c-osx64/lib_pypy/_ctypes/array.py",
 line 211, in __setitem__
    if ensure_objects(cobj) is not None:
  File 
"/Users/local/Downloads/pypy-c-jit-95034-d2dd59afa85c-osx64/lib_pypy/_ctypes/basics.py",
 line 15, in ensure_objects
    return ensure()
  File 
"/Users/local/Downloads/pypy-c-jit-95034-d2dd59afa85c-osx64/lib_pypy/_ctypes/primitive.py",
 line 396, in _ensure_objects
    assert self._objects is None
AssertionError
```

PyPy version: pypy-c-jit-95034-d2dd59afa85c-osx64/bin/pypy


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to