# Buggy code
def _get_via_file_cache(cls, py_info_cache, app_data, resolved_path, exe):
    key = sha256(
        str(resolved_path).encode("utf-8") if PY3 else str(resolved_path)
    ).hexdigest()
    py_info = None
    resolved_path_text = ensure_text(str(resolved_path))
    resolved_path_modified_timestamp = resolved_path.stat().st_mtime
    data_file = py_info_cache / "{}.json".format(key)
    with py_info_cache.lock_for_key(key):
        data_file_path = data_file.path
        if data_file_path.exists():  # if exists and matches load
            try:
                data = json.loads(data_file_path.read_text())
                if (
                    data["path"] == resolved_path_text
                    and data["st_mtime"] == resolved_path_modified_timestamp
                ):
                    logging.debug("get PythonInfo from %s for %s", data_file_path, exe)
                    py_info = cls._from_dict({k: v for k, v in data["content"].items()})
                else:
                    raise ValueError("force close as stale")
            except (KeyError, ValueError, OSError):
                logging.debug("remove PythonInfo %s for %s", data_file_path, exe)
                data_file_path.unlink()  # close out of date files
        if py_info is None:  # if not loaded run and save
            failure, py_info = _run_subprocess(cls, exe, app_data)
            if failure is None:
                file_cache_content = {
                    "st_mtime": resolved_path_modified_timestamp,
                    "path": resolved_path_text,
                    "content": py_info._to_dict(),
                }
                logging.debug("write PythonInfo to %s for %s", data_file_path, exe)
                data_file_path.write_text(
                    ensure_text(json.dumps(file_cache_content, indent=2))
                )
            else:
                py_info = failure
    return py_info


# Traceback (OSError)
(venv) C:\Users\IEUser\astpretty>virtualenv v -vvv --with-traceback
390 setup logging to NOTSET [DEBUG report:43]
468 could not create app data folder C:\Users\IEUser\AppData\Local\pypa\virtualenv due to FileNotFoundError(2, 'The system cannot find the path specified') [INFO app_data:54]
577 created temporary app data folder C:\Users\IEUser\AppData\Local\Temp\tmpaqvhomd3 [DEBUG app_data:32]
624 find interpreter for spec PythonSpec(path=c:\users\ieuser\astpretty\venv\scripts\python.exe) [INFO builtin:44]
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\IEUser\astpretty\venv\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\__main__.py", line 50, in run_with_catch
run(args, options)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\__main__.py", line 20, in run
session = cli_run(args, options)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\run\__init__.py", line 27, in cli_run
session = session_via_cli(args, options)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\run\__init__.py", line 35, in session_via_cli
parser = build_parser(args, options)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\run\__init__.py", line 71, in build_parser
parser._interpreter = interpreter = discover.interpreter
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\discover.py", line 44, in interpreter
self._interpreter = self.run()
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\builtin.py", line 33, in run
return get_interpreter(self.python_spec, self.app_data.folder)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\builtin.py", line 46, in get_interpreter
for interpreter, impl_must_match in propose_interpreters(spec, app_data):
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\builtin.py", line 60, in propose_interpreters
yield PythonInfo.from_exe(spec.path, app_data), True
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\py_info.py", line 293, in from_exe
proposed = proposed._resolve_to_system(app_data, proposed)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\py_info.py", line 328, in _resolve_to_system
target = cls.from_exe(target.system_executable, app_data)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\py_info.py", line 290, in from_exe
proposed = from_exe(cls, app_data, exe, raise_on_error=raise_on_error, ignore_cache=ignore_cache)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\cached_py_info.py", line 32, in from_exe
result = _get_from_cache(cls, py_info_cache, app_data, exe, ignore_cache=ignore_cache)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\cached_py_info.py", line 56, in _get_from_cache
py_info = _get_via_file_cache(cls, py_info_cache, app_data, exe_path, exe)
File "c:\users\ieuser\astpretty\venv\lib\site-packages\virtualenv\discovery\cached_py_info.py", line 68, in _get_via_file_cache
resolved_path_modified_timestamp = resolved_path.stat().st_mtime
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1776.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 1178, in stat
return self._accessor.stat(self)
OSError: [WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\IEUser\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'

# Fixed code
def _get_via_file_cache(cls, py_info_cache, app_data, resolved_path, exe):
    key = sha256(
        str(resolved_path).encode("utf-8") if PY3 else str(resolved_path)
    ).hexdigest()
    py_info = None
    resolved_path_text = ensure_text(str(resolved_path))
    try:
        resolved_path_modified_timestamp = resolved_path.stat().st_mtime
    except OSError:
        resolved_path_modified_timestamp = -1
    data_file = py_info_cache / "{}.json".format(key)
    with py_info_cache.lock_for_key(key):
        data_file_path = data_file.path
        if (
            data_file_path.exists() and resolved_path_modified_timestamp != 1
        ):  # if exists and matches load
            try:
                data = json.loads(data_file_path.read_text())
                if (
                    data["path"] == resolved_path_text
                    and data["st_mtime"] == resolved_path_modified_timestamp
                ):
                    logging.debug("get PythonInfo from %s for %s", data_file_path, exe)
                    py_info = cls._from_dict({k: v for k, v in data["content"].items()})
                else:
                    raise ValueError("force close as stale")
            except (KeyError, ValueError, OSError):
                logging.debug("remove PythonInfo %s for %s", data_file_path, exe)
                data_file_path.unlink()  # close out of date files
        if py_info is None:  # if not loaded run and save
            failure, py_info = _run_subprocess(cls, exe, app_data)
            if failure is None:
                file_cache_content = {
                    "st_mtime": resolved_path_modified_timestamp,
                    "path": resolved_path_text,
                    "content": py_info._to_dict(),
                }
                logging.debug("write PythonInfo to %s for %s", data_file_path, exe)
                data_file_path.write_text(
                    ensure_text(json.dumps(file_cache_content, indent=2))
                )
            else:
                py_info = failure
    return py_info