def checked_call(
        self, func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
    ) -> R:
        """Call a function and raise an errno-exception if applicable."""
        __tracebackhide__ = True
        try:
            return func(*args, **kwargs)
        except Error:
            raise
        except OSError as value:
            if not hasattr(value, "errno"):
                raise
            if sys.platform == "win32":
                try:
                    # error: Invalid index type "Optional[int]" for "dict[int, int]"; expected type "int"  [index]
                    # OK to ignore because we catch the KeyError below.
                    cls = self._geterrnoclass(_winerrnomap[value.errno])  # type:ignore[index]
                except KeyError:
                    raise value
            else:
                # we are not on Windows, or we got a proper OSError
                if value.errno is None:
                    cls = type(
                        "UnknownErrnoNone",
                        (Error,),
                        {"__module__": "py.error", "__doc__": None},
                    )
                else:
                    cls = self._geterrnoclass(value.errno)

            raise cls(f"{func.__name__}{args!r}")
Call a function and raise an errno-exception if applicable.
src/_pytest/_py/error.py