This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: invalid call of Windows API _popen() generating The input line is too long error message
Type: behavior Stage:
Components: Windows Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: tim.golden Nosy List: r.david.murray, ssbarnea, tim.golden
Priority: normal Keywords:

Created on 2010-08-27 11:42 by ssbarnea, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
bug_line_too_long.py ssbarnea, 2010-08-27 14:31
Messages (9)
msg115062 - (view) Author: Sorin Sbarnea (ssbarnea) * Date: 2010-08-27 11:42
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.
msg115072 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-27 13:17
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?
msg115077 - (view) Author: Sorin Sbarnea (ssbarnea) * Date: 2010-08-27 14:11
I'm currently building some samples (one that could be run on any Windows machine).
msg115083 - (view) Author: Sorin Sbarnea (ssbarnea) * Date: 2010-08-27 14:31
Here is a test file. It does contain 3 command lines that are similar but one of them is not working (cmd_2).
msg115097 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-27 15:35
Thanks, sorin.  This issue is at least affected by the fix to issue 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.
msg115104 - (view) Author: Sorin Sbarnea (ssbarnea) * Date: 2010-08-27 15:46
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.
msg115110 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2010-08-27 18:19
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.
msg116320 - (view) Author: Sorin Sbarnea (ssbarnea) * Date: 2010-09-13 15:52
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.
msg223149 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-15 21:08
@Tim can you pick this up?
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53908
2019-04-26 19:41:53BreamoreBoysetnosy: - BreamoreBoy
2014-07-15 21:56:51brian.curtinsetnosy: - brian.curtin
2014-07-15 21:08:26BreamoreBoysetnosy: + BreamoreBoy

messages: + msg223149
versions: + Python 3.4, Python 3.5, - Python 3.2
2011-06-01 06:21:13terry.reedysetversions: - Python 2.6, Python 2.5, Python 3.1
2010-09-13 15:52:24ssbarneasetmessages: + msg116320
2010-08-27 18:19:13tim.goldensetmessages: + msg115110
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
2010-08-27 16:30:00tim.goldensetassignee: tim.golden
2010-08-27 15:46:07ssbarneasetmessages: + msg115104
versions: + Python 2.5
2010-08-27 15:35:59r.david.murraysetnosy: + tim.golden, brian.curtin
messages: + msg115097
2010-08-27 14:31:19ssbarneasetfiles: + bug_line_too_long.py

messages: + msg115083
2010-08-27 14:11:50ssbarneasetmessages: + msg115077
2010-08-27 13:17:55r.david.murraysetnosy: + r.david.murray

messages: + msg115072
versions: - Python 2.5, Python 3.3
2010-08-27 11:42:17ssbarneacreate