diff --git a/api/GenApi.py b/api/GenApi.py index 5729c0aba5e927c7cee6c4daa8610e98b1d11833..ec17869232a5240437a9aaa309ed8e52d0e4c280 100644 --- a/api/GenApi.py +++ b/api/GenApi.py @@ -1400,7 +1400,8 @@ class API: tuple((a.python_arg for a in args)) + ("byref(ierr)", )) + ")\n") if name == "finalize": # special case for finalize() function - f.write(indent + "signal.signal(signal.SIGINT, oldsig)\n") + f.write(indent + "if oldsig is not None:\n") + f.write(indent + " signal.signal(signal.SIGINT, oldsig)\n") f.write(indent + "if ierr.value != 0:\n") if name == "getLastError": # special case for getLastError() function f.write(indent + " raise Exception('Could not get last error')\n") diff --git a/api/gmsh.py b/api/gmsh.py index ad660e64182c49c25fe9f90d8daad4d6d14951ab..13ad4c7f95dcf5cf1842ec3643cdd37b41468966 100644 --- a/api/gmsh.py +++ b/api/gmsh.py @@ -210,7 +210,8 @@ def finalize(): ierr = c_int() lib.gmshFinalize( byref(ierr)) - signal.signal(signal.SIGINT, oldsig) + if oldsig is not None: + signal.signal(signal.SIGINT, oldsig) if ierr.value != 0: raise Exception(logger.getLastError())