MCPcopy Index your code
hub / github.com/python/cpython / _safe_getenv

Function _safe_getenv

Lib/_colorize.py:449–454  ·  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

447def can_colorize(*, file: IO[str] | IO[bytes] | None = None) -> bool:
448
449 def _safe_getenv(k: str, fallback: str | None = None) -> str | None:
450 """Exception-safe environment retrieval. See gh-128636."""
451 try:
452 return os.environ.get(k, fallback)
453 except Exception:
454 return fallback
455
456 if file is None:
457 file = sys.stdout

Callers 1

can_colorizeFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…