Skip to content

Commit

Permalink
Fix restore_savestate
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Nov 20, 2024
1 parent 28ebfcc commit 649d4a4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2622,15 +2622,11 @@ static void nrnpy_store_savestate_(char** save_data, uint64_t* save_data_size) {

static void nrnpy_restore_savestate_(int64_t size, char* data) {
if (restore_savestate_) {
PyObject* args = PyTuple_New(1);
auto py_data = nb::steal(PyByteArray_FromStringAndSize(data, size));
nb::bytearray py_data(data, size);

Check warning on line 2625 in src/nrnpython/nrnpy_hoc.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrnpython/nrnpy_hoc.cpp#L2625

Added line #L2625 was not covered by tests
if (!py_data) {
hoc_execerror("SaveState:", "Data restore failure.");
}
// note: PyTuple_SetItem steals a ref to py_data
PyTuple_SetItem(args, 0, py_data.release().ptr());
auto result = nb::steal(PyObject_CallObject(restore_savestate_, args));
Py_DECREF(args);
auto result = nb::steal(PyObject_CallOneArg(restore_savestate_, py_data.ptr()));

Check warning on line 2629 in src/nrnpython/nrnpy_hoc.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrnpython/nrnpy_hoc.cpp#L2629

Added line #L2629 was not covered by tests
if (!result) {
hoc_execerror("SaveState:", "Data restore failure.");
}
Expand Down

0 comments on commit 649d4a4

Please sign in to comment.