Skip to content

Fix incorrect parsing of requested Python version as empty version specifiers - #4289

Merged
zanieb merged 1 commit into
mainfrom
zb/fix-exec-name
Jun 13, 2024
Merged

zanieb merged 1 commit into
mainfrom
zb/fix-exec-name

Conversation

@zanieb

@zanieb zanieb commented Jun 12, 2024 •

Copy link
Copy Markdown
Member

Before 0.2.10 we would parse --python=python as an executable name. After #4214, we started treating this as a Python version range request (with an empty version range). This is not entirely unreasonable, but it was an unexpected regression and I don't think VersionRequest should support empty ranges in its from_str implementation without more consideration.

@@ -1237,6 +1237,9 @@ impl FromStr for VersionRequest {
Ok(selector)
// e.g. `>=3.12.1,<3.12`
} else if let Ok(specifiers) = VersionSpecifiers::from_str(s) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is specifiers in this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry can you rephrase? It's an empty VersionSpecifiers that allows any version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does "python" get parsed as an empty VersionSpecifiers? I'm just trying to understand the data flow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes I can answer that :)

// e.g. `python3.12.1`
if let Some(remainder) = value.strip_prefix("python") {
if let Ok(version) = VersionRequest::from_str(remainder) {
return Self::Version(version);
}
}

Previously an empty remainder here would result in us not treating this as a Python version request, now it does. I didn't expect VersionSpecifiers to allow empty strings, but it makes sense in hindsight.

I'm going to need to split VersionRequest::Range out of VersionRequest (or something like that) to have the user experience I want — trying to figure out how best to do that next.

@zanieb
zanieb merged commit b43de79 into main Jun 13, 2024
@zanieb
zanieb deleted the zb/fix-exec-name branch June 13, 2024 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants