Avoid TOCTOU errors in .python-version reads (#5223)

## Summary

Not a big deal, but better to try the operation and handle the failure
case than to check if the file exists and _then_ read it.
This commit is contained in:
Charlie Marsh 2024-07-19 11:08:20 -04:00 committed by GitHub
parent ed9b820815
commit 2169902bd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 33 deletions

View file

@ -14,8 +14,8 @@ pub use crate::prefix::Prefix;
pub use crate::python_version::PythonVersion;
pub use crate::target::Target;
pub use crate::version_files::{
request_from_version_file, requests_from_version_file, version_file_exists,
versions_file_exists, PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME,
request_from_version_file, requests_from_version_file, PYTHON_VERSIONS_FILENAME,
PYTHON_VERSION_FILENAME,
};
pub use crate::virtualenv::{Error as VirtualEnvError, PyVenvConfiguration, VirtualEnvironment};
mod discovery;