[pypy-dev] PyCXX and PyPy status
armin.rigo at gmail.com
Tue Oct 2 16:55:10 EDT 2018
On Tue, 2 Oct 2018 at 21:09, Barry Scott <barry at barrys-emacs.org> wrote:
> Using PyPy 0.6.0 on macOS I managed to build a .so that crashed when imported.
I will assume that you mean PyPy2 6.0.0, and not PyPy3 nor the version 0.6.0.
> The reason is that the PyPy's C API does not allow tuples to be created.
You cannot change tuple objects after they "escaped" to become general
PyPy objects. You can only call PyTuple_SetItem() on a tuple object
that exists as a "PyObject *" but not yet as a PyPy object. That
means, mostly, you should only call PyTuple_SetItem() on the fresh
result of PyTuple_New() before the "PyObject *" is sent somewhere
else. In your example code, maybe the set() function makes the tuple
object escape in this way. Note that escaping tuples before they are
fully initialized can also sometimes create potential crashes on
> if (PyMapping_DelItemString (ptr(), const_cast<char*>(s.c_str())) == -1)
> if (PyMapping_DelItem (ptr(), *s) == -1)
I don't know how it ever worked, because PyMapping_DelItem and
PyMapping_DelItemString are not implemented, neither right now nor at
the time of release 6.0.0.
If you are using these two functions, please open an issue
we'll implement them.
More information about the pypy-dev