tests [python]: Survive FSE when accessing pythons from the store.

GitOrigin-RevId: dc13d59d2efd3110b318e6ed9446d33ae15f2d07
This commit is contained in:
Ilya.Kazakevich
2026-01-13 05:35:52 +00:00
committed by intellij-monorepo-bot
parent d2912a83a0
commit dc601f0dca
@@ -5,16 +5,23 @@ import com.intellij.ide.ApplicationInitializedListener
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
import com.intellij.python.community.services.systemPython.SystemPythonService
import org.jetbrains.annotations.TestOnly
import java.nio.file.FileSystemException
import kotlin.io.path.pathString
@TestOnly
internal class SystemPythonRootsFixer : ApplicationInitializedListener {
override suspend fun execute() {
val disposable = ApplicationManager.getApplication()
val pythonDirs = SystemPythonService()
.findSystemPythons()
.map { it.pythonBinary.toRealPath().parent.pathString }
.map {
try {
// It might throw FSE on Windows for pythons installed from store, see WinAppxTools
it.pythonBinary.toRealPath()
}
catch (_: FileSystemException) {
it.pythonBinary
}.parent.pathString
}
.toTypedArray()
VfsRootAccess.allowRootAccess(disposable, *pythonDirs)
}