link/fix-system-pythons

[python]: `PathShortenerTest`: do not throw an exception for relative paths.

`EelPath` is always absolute, so we used to throw an exception if relative path was provided.

It makes no sense to substitute anything in relative path, so we simply return it as is.

[python]: `SystemPythonService`: remove duplicates.


Merge-request: IJ-MR-183231
Merged-by: Ilya Kazakevich <ilya.kazakevich@jetbrains.com>

GitOrigin-RevId: c391a55fda0f372184279e444e9188f71bceba3e
This commit is contained in:
Ilya Kazakevich
2025-11-24 21:21:09 +00:00
committed by intellij-monorepo-bot
parent 4280168782
commit 6d732f5624
3 changed files with 22 additions and 13 deletions
@@ -11,6 +11,7 @@ import com.intellij.platform.eel.provider.getEelDescriptor
import com.jetbrains.python.PathShortener.Companion.create
import org.jetbrains.annotations.ApiStatus
import java.nio.file.Path
import kotlin.io.path.pathString
/**
* Replaces homepath with tilda and some well-known Windows vars as well.
@@ -58,10 +59,13 @@ class PathShortener private constructor(private val map: List<Pair<EelPath, Stri
}
/**
* Convert [path] to user-readable string replacing home with tild and so on
* Convert [path] to user-readable string replacing home with tilda and so on
*/
fun toString(path: Path): @NlsSafe String {
val pathDescriptor = path.getEelDescriptor()
if (!path.isAbsolute) { // eelPath doesn't support relative paths
return path.pathString
}
var result = path.asEelPath().toString()
for ((key, replaceWith) in map) {
assert(pathDescriptor == key.descriptor) { "path is on $pathDescriptor, replacer is on ${key.descriptor}" }