
The CPython differences documentation here: http://doc.pypy.org/en/latest/cpython_differences.html References the exception `SystemError('PyTuple_SetItem called on tuple after use of tuple")’ but it’s not clear when/why this exception gets triggered. I’m trying to use scipy with pypy, and the ODE integrator is raising this exception for code that works on CPython. I can’t figure out what I might change in the configuration or the ODE integrator, or whether to conclude that this is a bug in scipy’s compatibility with pypy. Thanks, --Bill

FYI, the following example illustrates this issue: from scipy.integrate import ode y0, t0 = [1.0j, 2.0], 0 def f(t, y, arg1): return [1j*arg1*y[0] + y[1], -arg1*y[1]**2] def jac(t, y, arg1): return [[1j*arg1, 1], [0, -arg1*2*y[1]]] r = ode(f, jac).set_integrator('zvode', method='bdf') r.set_initial_value(y0, t0).set_f_params(2.0).set_jac_params(2.0) t1 = 10 dt = 1 while r.successful() and r.t < t1: print(r.t+dt, r.integrate(r.t+dt)) From: William Hart <wehart@sandia.gov> Date: Friday, February 2, 2018 at 9:43 AM To: "pypy-dev@python.org" <pypy-dev@python.org> Cc: "Nicholson, Bethany L." <blnicho@sandia.gov> Subject: Help with PyTuple_SetItem error The CPython differences documentation here: http://doc.pypy.org/en/latest/cpython_differences.html References the exception `SystemError('PyTuple_SetItem called on tuple after use of tuple")’ but it’s not clear when/why this exception gets triggered. I’m trying to use scipy with pypy, and the ODE integrator is raising this exception for code that works on CPython. I can’t figure out what I might change in the configuration or the ODE integrator, or whether to conclude that this is a bug in scipy’s compatibility with pypy. Thanks, --Bill

Hi Hart, On 2 February 2018 at 17:43, Hart, William E <wehart@sandia.gov> wrote:
References the exception `SystemError('PyTuple_SetItem called on tuple after use of tuple")’ but it’s not clear when/why this exception gets triggered.
It's because scipy uses the CPython C API in a way that is arguably wrong, but most likely works fine on CPython. It would help if you can track down the source code of the .c file with the call to PyTuple_SetItem() that causes the crash. I tried to install scipy on my laptop but it seems to be quite involved so I gave up for now (it depends on non-Python packages). A bientôt, Armin.

Armin: Thanks for the update. I agree with your analysis. Bethany Nicholson and I concluded that the SciPy team isn't currently supporting PyPy, based on additional information we found online. We'll alert the scipy developers about this issue. Cheers, --Bill On 2/4/18, 10:54 AM, "Armin Rigo" <armin.rigo@gmail.com> wrote: Hi Hart, On 2 February 2018 at 17:43, Hart, William E <wehart@sandia.gov> wrote: > References the exception `SystemError('PyTuple_SetItem called on tuple after > use of tuple")’ but it’s not clear when/why this exception gets triggered. It's because scipy uses the CPython C API in a way that is arguably wrong, but most likely works fine on CPython. It would help if you can track down the source code of the .c file with the call to PyTuple_SetItem() that causes the crash. I tried to install scipy on my laptop but it seems to be quite involved so I gave up for now (it depends on non-Python packages). A bientôt, Armin.

FYI, the following example illustrates this issue: from scipy.integrate import ode y0, t0 = [1.0j, 2.0], 0 def f(t, y, arg1): return [1j*arg1*y[0] + y[1], -arg1*y[1]**2] def jac(t, y, arg1): return [[1j*arg1, 1], [0, -arg1*2*y[1]]] r = ode(f, jac).set_integrator('zvode', method='bdf') r.set_initial_value(y0, t0).set_f_params(2.0).set_jac_params(2.0) t1 = 10 dt = 1 while r.successful() and r.t < t1: print(r.t+dt, r.integrate(r.t+dt)) From: William Hart <wehart@sandia.gov> Date: Friday, February 2, 2018 at 9:43 AM To: "pypy-dev@python.org" <pypy-dev@python.org> Cc: "Nicholson, Bethany L." <blnicho@sandia.gov> Subject: Help with PyTuple_SetItem error The CPython differences documentation here: http://doc.pypy.org/en/latest/cpython_differences.html References the exception `SystemError('PyTuple_SetItem called on tuple after use of tuple")’ but it’s not clear when/why this exception gets triggered. I’m trying to use scipy with pypy, and the ODE integrator is raising this exception for code that works on CPython. I can’t figure out what I might change in the configuration or the ODE integrator, or whether to conclude that this is a bug in scipy’s compatibility with pypy. Thanks, --Bill

Hi Hart, On 2 February 2018 at 17:43, Hart, William E <wehart@sandia.gov> wrote:
References the exception `SystemError('PyTuple_SetItem called on tuple after use of tuple")’ but it’s not clear when/why this exception gets triggered.
It's because scipy uses the CPython C API in a way that is arguably wrong, but most likely works fine on CPython. It would help if you can track down the source code of the .c file with the call to PyTuple_SetItem() that causes the crash. I tried to install scipy on my laptop but it seems to be quite involved so I gave up for now (it depends on non-Python packages). A bientôt, Armin.

Armin: Thanks for the update. I agree with your analysis. Bethany Nicholson and I concluded that the SciPy team isn't currently supporting PyPy, based on additional information we found online. We'll alert the scipy developers about this issue. Cheers, --Bill On 2/4/18, 10:54 AM, "Armin Rigo" <armin.rigo@gmail.com> wrote: Hi Hart, On 2 February 2018 at 17:43, Hart, William E <wehart@sandia.gov> wrote: > References the exception `SystemError('PyTuple_SetItem called on tuple after > use of tuple")’ but it’s not clear when/why this exception gets triggered. It's because scipy uses the CPython C API in a way that is arguably wrong, but most likely works fine on CPython. It would help if you can track down the source code of the .c file with the call to PyTuple_SetItem() that causes the crash. I tried to install scipy on my laptop but it seems to be quite involved so I gave up for now (it depends on non-Python packages). A bientôt, Armin.
participants (2)
-
Armin Rigo
-
Hart, William E