mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-112559: Avoid unnecessary conversion attempts to enum_klass in signal.py (#113040)
This commit is contained in:
parent
0187a7e4ec
commit
050783cb37
4 changed files with 51 additions and 2 deletions
|
|
@ -22,9 +22,11 @@ if 'pthread_sigmask' in _globals:
|
|||
|
||||
|
||||
def _int_to_enum(value, enum_klass):
|
||||
"""Convert a numeric value to an IntEnum member.
|
||||
If it's not a known member, return the numeric value itself.
|
||||
"""Convert a possible numeric value to an IntEnum member.
|
||||
If it's not a known member, return the value itself.
|
||||
"""
|
||||
if not isinstance(value, int):
|
||||
return value
|
||||
try:
|
||||
return enum_klass(value)
|
||||
except ValueError:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue