Probe bytes and str variants for environ. This is because in python3: * _os (nt) on windows returns str, * _os (posix) on linux return bytes For more information check: * https://github.com/python/cpython/blob/main/Lib/importlib/_bootstrap_external.py#L34 * YA-1700
(environ_dict, key, default_value=None)
| 37 | executable = sys.executable or 'Y_PYTHON' |
| 38 | |
| 39 | def _probe(environ_dict, key, default_value=None): |
| 40 | """ Probe bytes and str variants for environ. |
| 41 | This is because in python3: |
| 42 | * _os (nt) on windows returns str, |
| 43 | * _os (posix) on linux return bytes |
| 44 | For more information check: |
| 45 | * https://github.com/python/cpython/blob/main/Lib/importlib/_bootstrap_external.py#L34 |
| 46 | * YA-1700 |
| 47 | """ |
| 48 | keys = [_b(key), _s(key)] |
| 49 | for key in keys: |
| 50 | if key in environ_dict: |
| 51 | return _b(environ_dict[key]) |
| 52 | |
| 53 | return _b(default_value) if isinstance(default_value, str) else default_value |
| 54 | |
| 55 | # This is the prefix in contrib/tools/python3/Lib/ya.make. |
| 56 | py_prefix = b'py/' |
no test coverage detected