Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gammu/src/smsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ static PyObject *SMSD_new(PyTypeObject * type, PyObject * args, PyObject * kwds)
if (self->config == NULL)
return NULL;

/* Disable exit on failure to allow Python to handle errors */
SMSD_SetExitOnFailure(self->config, FALSE);

return (PyObject *) self;
}

Expand Down
14 changes: 14 additions & 0 deletions test/test_smsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,17 @@ def test_smsd(self) -> None:

# Wait for it
smsd_thread.join()

def test_get_status_not_running(self) -> None:
"""
Test that GetStatus raises exception when SMSD is not running.

This test verifies the fix for the issue where GetStatus would cause
Python to exit instead of raising an exception when SMSD is not running.
The fix disables the exit_on_failure flag in the SMSD config.
"""
smsd = self.get_smsd()
# SMSD is not running, so GetStatus should raise an exception
# instead of causing Python to exit
with pytest.raises(gammu.GSMError):
smsd.GetStatus()