diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp
index 25536e55d57a5da7fb9e0ba4c198c161eac4dde4..daa49526656ff4b5b747c0d35dc41c815c314eb7 100644
--- a/src/PYTHON/python_impl.cpp
+++ b/src/PYTHON/python_impl.cpp
@@ -313,6 +313,9 @@ void PythonImpl::invoke_function(int ifunc, char *result)
       }
     } else if (itype == PTR) {
       pValue = PY_VOID_POINTER(lmp);
+    } else {
+      PyGILState_Release(gstate);
+      error->all(FLERR,"Unsupported variable type");
     }
     PyTuple_SetItem(pArgs,i,pValue);
   }