Skip to content

invalid call of Windows API _popen() generating The input line is too long error message #53908

Closed as not planned

Description

@ssbarnea
mannequin
BPO 9699
Nosy @tjguk, @bitdancer, @ssbarnea
Files
  • bug_line_too_long.py
  • 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 = 'https://github.com/tjguk'
    closed_at = None
    created_at = <Date 2010-08-27.11:42:17.599>
    labels = ['type-bug', 'OS-windows']
    title = 'invalid call of Windows API _popen() generating The input\tline is too long error message'
    updated_at = <Date 2019-04-26.19:41:53.020>
    user = 'https://github.com/ssbarnea'

    bugs.python.org fields:

    activity = <Date 2019-04-26.19:41:53.020>
    actor = 'BreamoreBoy'
    assignee = 'tim.golden'
    closed = False
    closed_date = None
    closer = None
    components = ['Windows']
    creation = <Date 2010-08-27.11:42:17.599>
    creator = 'ssbarnea'
    dependencies = []
    files = ['18662']
    hgrepos = []
    issue_num = 9699
    keywords = []
    message_count = 9.0
    messages = ['115062', '115072', '115077', '115083', '115097', '115104', '115110', '116320', '223149']
    nosy_count = 3.0
    nosy_names = ['tim.golden', 'r.david.murray', 'ssbarnea']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9699'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    Activity

    1. ssbarnea commented on Aug 27, 2010

      ssbarneamannequin
      MannequinAuthor

      Behavior: you get "The input line is too long." error message when you try to run an external process by using os.system(), subprocess.Popen() or other similar methods.

      The real command line limit is 8192 under Windows and in most cases (if not all) the cause for getting this message is not the length.

      The real cause is that if you even have a quote inside your command line you need to include the entire command in quote.

      Here are some details:
      http://stackoverflow.com/questions/682799/what-to-do-with-the-input-line-is-too-long-error-message/3583282#3583282
      http://msdn.microsoft.com/en-us/library/96ayss4b.aspx (see comment)

      Even if this is caused by a bug on Windows that is present for more than ten years I think Python needs to workaround it by adding the quotes when they are needed.

      This will prevent other developers from writing OS specific code in their Python programs in order to workaround this bug.

    2. bitdancer commented on Aug 27, 2010

      @bitdancer
      Member

      Python does not call _popen, though it does call cmd.exe (through CreateProcess) when shell=True in subprocess. Can you provide an example that shows this error occurring?

    3. ssbarnea commented on Aug 27, 2010

      ssbarneamannequin
      MannequinAuthor

      I'm currently building some samples (one that could be run on any Windows machine).

    4. ssbarnea commented on Aug 27, 2010

      ssbarneamannequin
      MannequinAuthor

      Here is a test file. It does contain 3 command lines that are similar but one of them is not working (cmd_2).

    5. bitdancer commented on Aug 27, 2010

      @bitdancer
      Member

      Thanks, sorin. This issue is at least affected by the fix to bpo-2304. I don't currently have an up-to-date version of 2.7 trunk on my windows VM, so I can't test your code there. (Note that 'import tee' needs to be removed before your test program will run.) Adding Tim and Brian to nosy so they can check it out. It is quite possible (even likely) that 2304 fixed this problem as well.

    6. ssbarnea commented on Aug 27, 2010

      ssbarneamannequin
      MannequinAuthor

      True about tee, I forgot to remove it. By the way, in case the other patch does not solve the issue we can use the quote_command() from
      http://github.com/ssbarnea/tendo/blob/master/tendo/tee.py to solve it.

    7. self-assigned this
      on Aug 27, 2010
    8. tjguk commented on Aug 27, 2010

      @tjguk
      Member

      I'll pick this up and try to decide what's best to
      do. I'm away from home for a few weeks and have only
      intermittent internet access. Thanks, Sorin, for
      a reproducible test case.

    9. changed the title [-]invalid call of Windows API _popen() generating The input line is too long error message[/-] [+]invalid call of Windows API _popen() generating The input line is too long error message[/+] on Aug 27, 2010
    10. ssbarnea commented on Sep 13, 2010

      ssbarneamannequin
      MannequinAuthor

      I made a small but important update to quote_command(), now it does quote the command line only under Windows because doing this under other platforms may break the command line.

    11. BreamoreBoy commented on Jul 15, 2014

      BreamoreBoymannequin
      Mannequin

      @tim can you pick this up?

    12. transferred this issue fromon Apr 10, 2022
    13. added
      pendingThe issue will be closed if no feedback is provided
      on Sep 21, 2025
    14. devdanzin commented on Sep 21, 2025

      @devdanzin
      Member

      Cannot reproduce on main (3.15) on Windows 11. Will close the issue unless someone can repro.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    OS-windowspendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions