Improve logging of interpreter implementation (#3791)

```
Found Python interpreter CPython 3.12.3 at...
```

instead of

```
Found Python interpreter cpython 3.12.3 at
```
This commit is contained in:
Zanie Blue 2024-05-23 11:00:45 -04:00 committed by GitHub
parent 81eff0ecc8
commit 306a4d7ce3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View file

@ -17,6 +17,12 @@ pub enum ImplementationName {
PyPy,
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub(crate) enum LenientImplementationName {
Known(ImplementationName),
Unknown(String),
}
impl ImplementationName {
pub(crate) fn iter() -> impl Iterator<Item = &'static ImplementationName> {
static NAMES: &[ImplementationName] =
@ -52,3 +58,21 @@ impl Display for ImplementationName {
}
}
}
impl From<&str> for LenientImplementationName {
fn from(s: &str) -> Self {
match ImplementationName::from_str(s) {
Ok(implementation) => Self::Known(implementation),
Err(_) => Self::Unknown(s.to_string()),
}
}
}
impl Display for LenientImplementationName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Known(implementation) => implementation.fmt(f),
Self::Unknown(name) => f.write_str(name),
}
}
}