From 46595eef151a12a0aafabe7e8c96763e9de04f98 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:00:13 -0700 Subject: [PATCH] Check that errno is not None (#18084) Unblocks typeshed sync --- mypy/build.py | 1 + mypy/modulefinder.py | 1 + 2 files changed, 2 insertions(+) diff --git a/mypy/build.py b/mypy/build.py index ff9b48d2d7b4..4745610d7920 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -2140,6 +2140,7 @@ def parse_file(self, *, temporary: bool = False) -> None: # other systems, but os.strerror(ioerr.errno) does not, so we use that. # (We want the error messages to be platform-independent so that the # tests have predictable output.) + assert ioerr.errno is not None raise CompileError( [ "mypy: can't read file '{}': {}".format( diff --git a/mypy/modulefinder.py b/mypy/modulefinder.py index 9b15f2aff90e..bc11c1304776 100644 --- a/mypy/modulefinder.py +++ b/mypy/modulefinder.py @@ -777,6 +777,7 @@ def get_search_dirs(python_executable: str | None) -> tuple[list[str], list[str] print(err.stdout) raise except OSError as err: + assert err.errno is not None reason = os.strerror(err.errno) raise CompileError( [f"mypy: Invalid python executable '{python_executable}': {reason}"]