Skip to content

Commit 38ba11d

Browse files
committed
Remove distutils.util.strtobool deprecated in PEP 632 (Python 3.10)
https://peps.python.org/pep-0632/
1 parent f5f9c47 commit 38ba11d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

aws_xray_sdk/sdk_config.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import logging
3-
from distutils.util import strtobool
43

54
log = logging.getLogger(__name__)
65

@@ -40,10 +39,12 @@ def __get_enabled_from_env(cls):
4039
4140
:return: bool - True if it is enabled, False otherwise.
4241
"""
43-
env_var_str = os.getenv(cls.XRAY_ENABLED_KEY, 'true')
44-
try:
45-
return bool(strtobool(env_var_str))
46-
except ValueError:
42+
env_var_str = os.getenv(cls.XRAY_ENABLED_KEY, 'true').lower()
43+
if env_var_str in ('y', 'yes', 't', 'true', 'on', '1'):
44+
return True
45+
elif env_var_str in ('n', 'no', 'f', 'false', 'off', '0'):
46+
return False
47+
else:
4748
log.warning("Invalid literal passed into environment variable `AWS_XRAY_SDK_ENABLED`. Defaulting to True...")
4849
return True # If an invalid parameter is passed in, we return True.
4950

0 commit comments

Comments
 (0)