Skip to content

Accept path-like subprocess args (Python 3.8 compatibility) #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

achimnol
Copy link
Contributor

@achimnol achimnol commented Apr 7, 2020

This PR resolves #328.

@achimnol achimnol changed the title Accept pathlike subprocess args Accept path-like subprocess args Apr 7, 2020
@achimnol achimnol changed the title Accept path-like subprocess args Accept path-like subprocess args (Python 3.8 compatibility) Apr 8, 2020
@1st1
Copy link
Member

1st1 commented May 13, 2020

Could you please squash all commits and rebase against master?

* Also add subprocess test case using Path object

* uvloop already handles path-like cwd correctly, so I just
  copy-and-pasted the same logic to _init_args() method.

* The standard library uses "isinstance(obj, os.PathLike)" to check
  if an object is path-like, but os.PathLike exists as of Python 3.6.
  Since uvloop needs to support Python 3.5, we should use manual check
  for existence of the __fspath__ attribute.

* According to the official Python documentation:

  - https://docs.python.org/3/library/subprocess.html#subprocess.Popen
    The subprocess.Popen() constructor support path-like objects since
    Python 3.6 on POSIX and since Python 3.8 on Windows.

  - https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.subprocess_exec
    This page does not mention about path-like objects,
    but as of Python 3.8, it DOES support path-like objects.
@achimnol achimnol force-pushed the fix/accept-pathlike-subprocess-args branch from 22bb71f to 41a1ef8 Compare May 16, 2020 14:00
@achimnol
Copy link
Contributor Author

I've rebased and squashed the branch.

@1st1 1st1 merged commit 0d14ec6 into MagicStack:master May 16, 2020
@1st1
Copy link
Member

1st1 commented May 16, 2020

Thank you!

@achimnol achimnol deleted the fix/accept-pathlike-subprocess-args branch May 17, 2020 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accept path-like objects for subprocess APIs
2 participants