Skip to content
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

asyncio.create_subprocess_exec doesn't accept pathlib.Path like subprocess does #79427

Closed
lilydjwg mannequin opened this issue Nov 14, 2018 · 5 comments
Closed

asyncio.create_subprocess_exec doesn't accept pathlib.Path like subprocess does #79427

lilydjwg mannequin opened this issue Nov 14, 2018 · 5 comments
Labels
3.8 (EOL) end of life topic-asyncio type-feature A feature request or enhancement

Comments

@lilydjwg
Copy link
Mannequin

lilydjwg mannequin commented Nov 14, 2018

BPO 35246
Nosy @asvetlov, @lilydjwg, @1st1, @miss-islington
PRs
  • bpo-35246: fix support for path-like args in asyncio subprocess #13628
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-05-29.06:51:26.488>
    created_at = <Date 2018-11-14.13:50:49.662>
    labels = ['type-feature', '3.8', 'expert-asyncio']
    title = "asyncio.create_subprocess_exec doesn't accept pathlib.Path like subprocess does"
    updated_at = <Date 2019-05-29.06:51:26.487>
    user = 'https://github.com/lilydjwg'

    bugs.python.org fields:

    activity = <Date 2019-05-29.06:51:26.487>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-29.06:51:26.488>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2018-11-14.13:50:49.662>
    creator = 'lilydjwg'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35246
    keywords = ['patch']
    message_count = 5.0
    messages = ['329907', '343701', '343729', '343771', '343864']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'lilydjwg', 'yselivanov', 'miss-islington']
    pr_nums = ['13628']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue35246'
    versions = ['Python 3.8']

    @lilydjwg
    Copy link
    Mannequin Author

    lilydjwg mannequin commented Nov 14, 2018

    When I pass pathlib.Path to asyncio.create_subprocess_exec I get:

    TypeError: program arguments must be a bytes or text string, not PosixPath

    It's not so good when subprocess accepts this kind of arguments without issues. So can you add support for this?

    @lilydjwg lilydjwg mannequin added 3.7 (EOL) end of life topic-asyncio type-feature A feature request or enhancement labels Nov 14, 2018
    @asvetlov
    Copy link
    Contributor

    All we need is program = os.fspath(program) in base_events.py subprocess_exec() method.

    Is anybody volunteered to make a patch (with test and docs update, sure)?

    @asvetlov asvetlov added 3.8 (EOL) end of life and removed 3.7 (EOL) end of life labels May 27, 2019
    @lilydjwg
    Copy link
    Mannequin Author

    lilydjwg mannequin commented May 28, 2019

    All we need is program = os.fspath(program) in base_events.py subprocess_exec() method.

    I don't think so. The arguments could be pathlib.Path too.

    We can update the isinstance(arg, (str, bytes)) check so the args pass on to subprocess.Popen. It will work in the POSIX part but there is an issue (bpo-33617, bpo-31961) in Windows part: subprocess.list2cmdline doesn't accept pathlib.Path.

    @asvetlov
    Copy link
    Contributor

    Aha, I see. You are right.
    Let's drop checks for cmd/program/args types but left to subprocess do these checks.
    This approach avoiding complex checking/converting logic in asyncio itself and reduces code duplication.

    @miss-islington
    Copy link
    Contributor

    New changeset 744c08a by Miss Islington (bot) (依云) in branch 'master':
    bpo-35246: fix support for path-like args in asyncio subprocess (GH-13628)
    744c08a

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life topic-asyncio type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants