diff --git a/mypy/config_parser.py b/mypy/config_parser.py index d5552186ecc70..132a77cf94f46 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -168,7 +168,7 @@ def parse_config_file(options: Options, set_strict_flags: Callable[[], None], continue try: if is_toml(config_file): - with open(config_file, encoding="utf-8") as f: + with open(config_file, 'rb', encoding="utf-8") as f: toml_data = tomli.load(f) # Filter down to just mypy relevant toml keys toml_data = toml_data.get('tool', {}) diff --git a/mypy/modulefinder.py b/mypy/modulefinder.py index 6cebd7db8bc0b..1570a322a6802 100644 --- a/mypy/modulefinder.py +++ b/mypy/modulefinder.py @@ -434,7 +434,7 @@ def _is_compatible_stub_package(self, stub_dir: str) -> bool: if os.path.isfile(metadata_fnam): # Delay import for a possible minor performance win. import tomli - with open(metadata_fnam, 'r', encoding="utf-8") as f: + with open(metadata_fnam, 'rb', encoding="utf-8") as f: metadata = tomli.load(f) if self.python_major_ver == 2: return bool(metadata.get('python2', False))