Skip to content

Fix AttributeError when accessing sh.SignalException_SIGUSR1 / SIGUSR2 - #792

Merged
amoffat merged 2 commits into
developfrom
copilot/fix-access-exception-signalexception-sigusr1-sigus
Jul 23, 2026
Merged

amoffat merged 2 commits into
developfrom
copilot/fix-access-exception-signalexception-sigusr1-sigus

Conversation

Copilot AI commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Accessing sh.SignalException_SIGUSR1 or sh.SignalException_SIGUSR2 raised an AttributeError because the regex used to parse exception names (SIG[a-zA-Z]+) rejected digit suffixes, truncating SIGUSR1 → SIGUSR before the getattr(signal, ...) lookup.

Changes

  • src/sh/__init__.py: Extend rc_exc_regex character class from SIG[a-zA-Z]+ to SIG[a-zA-Z0-9]+, allowing digit-suffixed signal names to match in full.
  • tests/sh_test.py: Add test_signal_exception_sigusr regression test asserting both SignalException_SIGUSR1 and SignalException_SIGUSR2 are accessible and are subclasses of SignalException.
# Previously raised AttributeError: module 'signal' has no attribute 'SIGUSR'
sh.SignalException_SIGUSR1  # now works
sh.SignalException_SIGUSR2  # now works

References #791, which removed these names from the stubs to work around the runtime crash rather than fixing it.

…ion_SIGUSR2

The regex `rc_exc_regex` used `SIG[a-zA-Z]+` which does not match digit
suffixes. Signal names like SIGUSR1/SIGUSR2 were truncated to "SIGUSR",
causing `getattr(signal, 'SIGUSR')` to raise an AttributeError.

Extend the character class to `SIG[a-zA-Z0-9]+` so the full name is
captured, and add a regression test. References #791.
Copilot AI changed the title [WIP] Fix access exception for sh.SignalException_SIGUSR1 and SIGUSR2 Fix AttributeError when accessing sh.SignalException_SIGUSR1 / SIGUSR2 Jul 23, 2026
Copilot AI requested a review from amoffat July 23, 2026 20:49
@amoffat
amoffat marked this pull request as ready for review July 23, 2026 20:55
@amoffat
amoffat merged commit 9b61fdc into develop Jul 23, 2026
23 checks passed
@amoffat
amoffat deleted the copilot/fix-access-exception-signalexception-sigusr1-sigus branch July 23, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants