Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/sh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class CommandNotFound(AttributeError):
pass


rc_exc_regex = re.compile(r"(ErrorReturnCode|SignalException)_((\d+)|SIG[a-zA-Z]+)")
rc_exc_regex = re.compile(r"(ErrorReturnCode|SignalException)_((\d+)|SIG[a-zA-Z0-9]+)")
rc_exc_cache: Dict[str, Type[ErrorReturnCode]] = {}

SIGNAL_MAPPING = {
Expand Down
10 changes: 10 additions & 0 deletions tests/sh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,16 @@ def test_decode_error_handling(self):
)
self.assertEqual(p, "test")

def test_signal_exception_sigusr(self):
"""Regression test for gh-791: SIGUSR1/SIGUSR2 names contain digits,
which previously caused the signal-name regex to truncate them."""
import sh

self.assertIsNotNone(sh.SignalException_SIGUSR1)
self.assertIsNotNone(sh.SignalException_SIGUSR2)
self.assertTrue(issubclass(sh.SignalException_SIGUSR1, sh.SignalException))
self.assertTrue(issubclass(sh.SignalException_SIGUSR2, sh.SignalException))

def test_signal_exception(self):
from sh import SignalException_15

Expand Down
Loading