[pypy-issue] Issue #2625: Ctypes cast does not work on string like objects (pypy/pypy)

Mihnea Saracin issues-reply at bitbucket.org
Mon Aug 7 08:18:28 EDT 2017


New issue 2625: Ctypes cast does not work on string like objects
https://bitbucket.org/pypy/pypy/issues/2625/ctypes-cast-does-not-work-on-string-like

Mihnea Saracin:

Running on PyPy, the attached script gives the following traceback, but on Cpython everything works fine.
```
#!python

  File "test_struct_struct.py", line 20, in <module>
    s = cast(data, ptr)[0]
  File "/home/mihnea/Downloads/Issue1213/source_pypy/pypy/lib-python/2.7/ctypes/__init__.py", line 501, in cast
    return _cast_addr(obj, obj, typ)
  File "/home/mihnea/Downloads/Issue1213/source_pypy/pypy/lib_pypy/_ctypes/pointer.py", line 148, in _cast_addr
    % (type(obj),))
TypeError: cast() argument 1 must be a pointer, not <type 'str'>
```
 This script is part of ctypes/test/test_byteswap.py lines 196-220.




More information about the pypy-issue mailing list