[pypy-issue] [issue1233] str() types can't be used with ctypes's py_object()

Marcus von Appen tracker at bugs.pypy.org
Sun Aug 12 11:24:53 CEST 2012

New submission from Marcus von Appen <mva at sysfault.org>:

Passing string objects to e.g. CFUNCTYPE callbacks via ctypes can currently only be
achieved using CPython, since pypy's implementation insists on using weakref'able
types for py_object() capsules.

Python 2.7.2 (341e1e3821fff77db3bb5cdb7a4851626298c44e, Jul 19 2012, 17:26:59)
[PyPy 1.9.0] on freebsd9
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``pypy is more stable than debian''
>>>> from ctypes import *
>>>> p = "Hello"
>>>> objp = py_object(p)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/pypy1.9/lib_pypy/_ctypes/primitive.py", line 312, in __init__
    self.value = value
  File "/usr/local/lib/pypy1.9/lib_pypy/_ctypes/primitive.py", line 214, in _setvalue
    num = pyobj_container.add(val)
  File "/usr/local/lib/pypy1.9/lib_pypy/_ctypes/primitive.py", line 56, in add
TypeError: cannot create weak reference to 'str' object

messages: 4650
nosy: marcusva, pypy-issue
priority: bug
release: 1.9
status: unread
title: str() types can't be used with ctypes's py_object()

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list