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
invalid call of Windows API _popen() generating The input line is too long error message #53908
Comments
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: 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. |
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? |
I'm currently building some samples (one that could be run on any Windows machine). |
Here is a test file. It does contain 3 command lines that are similar but one of them is not working (cmd_2). |
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. |
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 |
I'll pick this up and try to decide what's best to |
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. |
@tim can you pick this up? |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: