From 4eedfeb774ffa2a27bef059161fd25d9918fe3ab Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 12 Feb 2022 22:43:18 -0500 Subject: [PATCH] detect if LAMMPS library initialization failed and raise an exception --- python/lammps/core.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/lammps/core.py b/python/lammps/core.py index d934ee1baa..23002b210c 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -410,6 +410,10 @@ class lammps(object): pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object] self.lmp = c_void_p(pythonapi.PyCObject_AsVoidPtr(ptr)) + # check if library initilialization failed + if not self.lmp: + raise(RuntimeError("Failed to initialize LAMMPS object")) + # optional numpy support (lazy loading) self._numpy = None