MCPcopy Index your code
hub / github.com/RustPython/RustPython / _safe_getenv

Function _safe_getenv

Lib/_colorize.py:276–281  ·  view source on GitHub ↗

Exception-safe environment retrieval. See gh-128636.

(k: str, fallback: str | None = None)

Source from the content-addressed store, hash-verified

274def can_colorize(*, file: IO[str] | IO[bytes] | None = None) -> bool:
275
276 def _safe_getenv(k: str, fallback: str | None = None) -> str | None:
277 """Exception-safe environment retrieval. See gh-128636."""
278 try:
279 return os.environ.get(k, fallback)
280 except Exception:
281 return fallback
282
283 if file is None:
284 file = sys.stdout

Callers 1

can_colorizeFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected