From 2abdbab8ff0e543371563510432e0bf2ace04b8f Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 21 Jan 2024 13:32:05 -0800 Subject: [PATCH] --- xarray/core/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xarray/core/utils.py b/xarray/core/utils.py index 3bbf06cf967..7111ebf2c0d 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -1248,7 +1248,12 @@ def find_stack_level(test_mode=False) -> int: pkg_dir = Path(xr.__file__).parent test_dir = pkg_dir / "tests" - std_lib_dir = Path(sys.modules["os"].__file__).parent # Standard library path + std_lib_path = sys.modules["os"].__file__ + # Mostly to appease mypy; I don't think this can happen... + if std_lib_path is None: + return 0 + + std_lib_dir = Path(std_lib_path).parent # Standard library path frame = inspect.currentframe() n = 0