Skip to content

Commit

Permalink
Merge pull request astropy#16805 from eerovaher/rm-signal_number_to_name
Browse files Browse the repository at this point in the history
Remove `signal_number_to_name()`
  • Loading branch information
pllim authored Aug 6, 2024
2 parents bb40f07 + 54e9d19 commit db76cf2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
16 changes: 0 additions & 16 deletions astropy/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import locale
import os
import re
import signal
import sys
import threading
import traceback
Expand Down Expand Up @@ -291,21 +290,6 @@ def find_api_page(obj, version=None, openinbrowser=True, timeout=None):
return resurl


def signal_number_to_name(signum):
"""
Given an OS signal number, returns a signal name. If the signal
number is unknown, returns ``'UNKNOWN'``.
"""
# Since these numbers and names are platform specific, we use the
# builtin signal module and build a reverse mapping.

signal_to_name_map = {
k: v for v, k in signal.__dict__.items() if v.startswith("SIG")
}

return signal_to_name_map.get(signum, "UNKNOWN")


# _has_hidden_attribute() can be deleted together with deprecated is_path_hidden() and
# walk_skip_hidden().
if sys.platform == "win32":
Expand Down
6 changes: 0 additions & 6 deletions astropy/utils/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ def test_isiterable():
assert misc.isiterable(np.array([1, 2, 3])) is True


def test_signal_number_to_name_no_failure():
# Regression test for #5340: ensure signal_number_to_name throws no
# AttributeError (it used ".iteritems()" which was removed in Python3).
misc.signal_number_to_name(0)


@pytest.mark.remote_data
def test_api_lookup():
try:
Expand Down
5 changes: 2 additions & 3 deletions astropy/utils/xml/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import os
import subprocess
from signal import Signals


def validate_schema(filename, schema_file):
Expand Down Expand Up @@ -47,10 +48,8 @@ def validate_schema(filename, schema_file):
if p.returncode == 127:
raise OSError("xmllint not found, so can not validate schema")
elif p.returncode < 0:
from astropy.utils.misc import signal_number_to_name

raise OSError(
f"xmllint was terminated by signal '{signal_number_to_name(-p.returncode)}'"
f"xmllint was terminated by signal '{Signals(-p.returncode).name}'"
)

return p.returncode, stdout, stderr

0 comments on commit db76cf2

Please sign in to comment.