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

popen fails when there are two or more pathnames/parameters with spaces #46105

Closed
shoermann mannequin opened this issue Jan 9, 2008 · 4 comments
Closed

popen fails when there are two or more pathnames/parameters with spaces #46105

shoermann mannequin opened this issue Jan 9, 2008 · 4 comments
Labels
OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@shoermann
Copy link
Mannequin

shoermann mannequin commented Jan 9, 2008

BPO 1772
Nosy @tiran
Files
  • popen_bug.py: Code that shows the bug
  • 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 2008-01-20.19:56:54.938>
    created_at = <Date 2008-01-09.06:22:57.480>
    labels = ['type-bug', 'library', 'OS-windows']
    title = 'popen fails when there are two or more pathnames/parameters with spaces'
    updated_at = <Date 2008-01-20.19:56:54.936>
    user = 'https://bugs.python.org/shoermann'

    bugs.python.org fields:

    activity = <Date 2008-01-20.19:56:54.936>
    actor = 'christian.heimes'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-01-20.19:56:54.938>
    closer = 'christian.heimes'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2008-01-09.06:22:57.480>
    creator = 'shoermann'
    dependencies = []
    files = ['9164']
    hgrepos = []
    issue_num = 1772
    keywords = []
    message_count = 4.0
    messages = ['59580', '59898', '59925', '61358']
    nosy_count = 3.0
    nosy_names = ['christian.heimes', 'thomaslee', 'shoermann']
    pr_nums = []
    priority = 'normal'
    resolution = 'works for me'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1772'
    versions = ['Python 2.5', 'Python 2.4']

    @shoermann
    Copy link
    Mannequin Author

    shoermann mannequin commented Jan 9, 2008

    If commands similar to this (including all quotation
    marks) '"C:\\Program Files\\test.bat" blah "C:\\Data Files\\test2.txt"'
    are executed using popen, then the following is returned from
    stderr "'C:\\Program' is not recognized as an internal or external
    command,\noperable program or batch file.\n". No use of quotation has
    been able to fix this. As soon as there is more than one pair of
    quotations inside the command string popen will not handle the command
    correctly.

    @shoermann shoermann mannequin added stdlib Python modules in the Lib dir OS-windows type-bug An unexpected behavior, bug, or error labels Jan 9, 2008
    @thomaslee
    Copy link
    Mannequin

    thomaslee mannequin commented Jan 14, 2008

    Do you have a code sample that reproduces this issue? Which popen module
    and/or function are you using to execute this command?

    @shoermann
    Copy link
    Mannequin Author

    shoermann mannequin commented Jan 14, 2008

    I have attached some code that demonstrates the bug. You need to run it
    on Windows and you need to place some bat file (it doesn't need to do
    anything just exist) at C:\Program Files\test.bat (or change the
    reference in the code, but it does need to include spacing). The first
    popen call works the second popen call will fail, because there are 2
    pathnames in the code with spaces. I am using the popen4 module in os
    but I also tested popen2 and popen3 and they do the same thing.

    @tiran
    Copy link
    Member

    tiran commented Jan 20, 2008

    The popen*() function don't quote the paths for you. Please use the
    subprocess module. It takes care of the quoting on Windows.

    @tiran tiran closed this as completed Jan 20, 2008
    @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
    OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant