From acb23dce3c94e0e92ab15f1843b6e77c22240b50 Mon Sep 17 00:00:00 2001 From: konstin Date: Tue, 20 Jun 2023 19:53:32 +0200 Subject: [PATCH] Fix subprocess.run on Windows Python 3.7 (#5220) ## Summary From the [subprocess docs](https://docs.python.org/3/library/subprocess.html#subprocess.Popen): > Changed in version 3.6: args parameter accepts a path-like object if shell is False and a sequence containing path-like objects on POSIX. > > Changed in version 3.8: args parameter accepts a path-like object if shell is False and a sequence containing bytes and path-like objects on Windows. We want to support python 3.7 on windows, so we need to convert the `Path` into a `str` --- python/ruff/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/ruff/__main__.py b/python/ruff/__main__.py index 1631082fbe..44384bc14b 100644 --- a/python/ruff/__main__.py +++ b/python/ruff/__main__.py @@ -32,5 +32,7 @@ def find_ruff_bin() -> Path: if __name__ == "__main__": ruff = find_ruff_bin() - completed_process = subprocess.run([ruff, *sys.argv[1:]]) + # Passing a path-like to `subprocess.run()` on windows is only supported in 3.8+, + # but we also support 3.7 + completed_process = subprocess.run([os.fsdecode(ruff), *sys.argv[1:]]) sys.exit(completed_process.returncode)