mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-16 21:38:31 +00:00
Avoid panicking when encountering an invalid Python version during uv python list
(#7131)
Closes https://github.com/astral-sh/uv/issues/7129 Not entirely sure about the best approach yet.
This commit is contained in:
parent
8a0e1fde33
commit
8eff8aab0b
6 changed files with 44 additions and 11 deletions
|
@ -282,7 +282,9 @@ impl ManagedPythonInstallation {
|
|||
|
||||
/// The [`PythonVersion`] of the toolchain.
|
||||
pub fn version(&self) -> PythonVersion {
|
||||
self.key.version()
|
||||
self.key
|
||||
.version()
|
||||
.expect("Managed Python installations should always have valid versions")
|
||||
}
|
||||
|
||||
pub fn implementation(&self) -> &ImplementationName {
|
||||
|
@ -329,13 +331,17 @@ impl ManagedPythonInstallation {
|
|||
let stdlib = if matches!(self.key.os, Os(target_lexicon::OperatingSystem::Windows)) {
|
||||
self.python_dir().join("Lib")
|
||||
} else {
|
||||
let version = self
|
||||
.key
|
||||
.version()
|
||||
.expect("Managed Python installations should always have valid versions");
|
||||
let python = if matches!(
|
||||
self.key.implementation,
|
||||
LenientImplementationName::Known(ImplementationName::PyPy)
|
||||
) {
|
||||
format!("pypy{}", self.key.version().python_version())
|
||||
format!("pypy{}", version.python_version())
|
||||
} else {
|
||||
format!("python{}", self.key.version().python_version())
|
||||
format!("python{}", version.python_version())
|
||||
};
|
||||
self.python_dir().join("lib").join(python)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue