PY-48506 #pr2032 Support PathLike objects for subprocess

This fixes https://youtrack.jetbrains.com/issue/PY-48506/error-on-pydevmonkey-in-debug-mode-AttributeError-PosixPath-object-has-no-attribute-endswith by checking if the path is `PathLike`, and calling `__fspath__()` to get the string version of the path.

GitOrigin-RevId: 012913359ea48e2798a80ebe2d0732ba8297daa7
This commit is contained in:
Eyal Halpern Shalev
2022-05-30 13:08:34 +03:00
committed by intellij-monorepo-bot
parent 181b975dfa
commit 2381494f91

View File

@@ -108,6 +108,8 @@ def starts_with_python_shebang(path):
def is_python(path):
if isinstance(path, os.PathLike):
path = path.__fspath__()
if path.endswith("'") or path.endswith('"'):
path = path[1:len(path) - 1]
filename = os.path.basename(path).lower()