[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> My vote is for leaving this alone and letting the higher level
> functions be more clever. Changing this function is certain to 
> break existing code in unpredictable ways.

That is sensible.  Marking this as closed.

--
resolution:  -> wont fix
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-14 Thread Steve Dower

Steve Dower added the comment:

Automatically quoting arguments is more complicated than simply concatenating 
quotes, unfortunately, and people are guaranteed to have come up with ways to 
make it work already.

My vote is for leaving this alone and letting the higher level functions be 
more clever. Changing this function is certain to break existing code in 
unpredictable ways.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I no longer have a Windows box to test this but any proposed patch needs to 
make sure it doesn't break code that is already manually escaping the inputs.

--
nosy: +loewis, steve.dower, tim.golden, tim.peters

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-13 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
Removed message: http://bugs.python.org/msg222989

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> I believe the problem lies with the way that Windows implements 
> the 'exec' functions.

Yes, that is that cause of the observed behavior.  See the first note in the 
remarks section on the relevant MSDN entry at 
http://msdn.microsoft.com/en-us/library/431x4c1w.aspx :

"""
Spaces embedded in strings may cause unexpected behavior; for example, passing 
_exec the string "hi there" will result in the new process getting two 
arguments, "hi" and "there". If the intent was to have the new process open a 
file named "hi there", the process would fail. You can avoid this by quoting 
the string: "\"hi there\"".
"""

The 'exec' functions are more low level and more arcane than most people would 
like.  Python exposes that functionality with all its beauty and all its warts. 
 David Murray is right in saying that you likely need one of the higher level 
modules such as subprocess with shell=True.

I looked through the code in Modules/posixmodule.c and didn't any code on our 
part that exacerbates the behavior.

Knowing that the cause is the underlying function still leaves the question of 
whether to apply a patch the mitigates the problem (possibly breaking some code 
that relies on the existing behavior) or whether to live with the facts-of-life 
that accompany low level O/S functions.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-13 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> I believe the problem lies with the way that Windows implements 
> the 'exec' functions.

Yes, that is that cause of the observed behavior.  See the first note in the 
remarks section on the relevant MSDN entry at 
http://msdn.microsoft.com/en-us/library/431x4c1w.aspx :

"""
Spaces embedded in strings may cause unexpected behavior; for example, passing 
_exec the string "hi there" will result in the new process getting two 
arguments, "hi" and "there". If the intent was to have the new process open a 
file named "hi there", the process would fail. You can avoid this by quoting 
the string: "\"hi there\"".
"""

The 'exec' functions are more low level and more arcane than most people would 
like.  Python exposes that functionality with all its beauty and all its warts. 
 David Murray is right in saying that you likely need one of the higher level 
modules such as subprocess with shell=True.

I looked through the code in Modules/posixmodule.c and didn't any code on our 
part that exacerbates the behavior.  I recommend closing this as just one of 
the facts-of-life when dealing with low level functionality.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-07-13 Thread Mark Lawrence

Mark Lawrence added the comment:

I believe the patch on #1576120 is related to this but it was never reviewed.

--
nosy: +BreamoreBoy
versions: +Python 3.4, Python 3.5 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-02-06 Thread Zachary Ware

Changes by Zachary Ware :


--
nosy: +zach.ware

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-02-04 Thread R. David Murray

R. David Murray added the comment:

I believe the problem lies with the way that Windows implements the 'exec' 
functions.  Windows isn't posix, and sometimes its attempts to fake it go 
rather badly.  So, I'm not sure what the actual rules are, but whatever they 
are there should at least be a mention/pointer in the documentation about it.

Really, if you want to be cross platform you should use subprocess.  exec 
doesn't really even exec (replace the current process) on windows, if I 
understand correctly.

By the way, -c accepts strings with embedded newlines, something I didn't know 
for a long time :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-02-03 Thread Florian Bruhin

Florian Bruhin added the comment:

I can't test this right now, but I'd guess you also have to escape a " inside 
an argument (with \" presumably), and a \ with \\. Maybe more, no idea.

Actually the documentation doesn't say anything about me _having_ to escape 
anything, so I'd assume I don't have to. I'm calling a python function after 
all, and not using a shell.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-02-01 Thread Saimadhav Heblikar

Saimadhav Heblikar added the comment:

i have tried a workaround for this issue by explicitly escaping args so that 
same result is produced on all platforms.this patch does NOT change the 
behavior on non-NT platforms.
If this patch is accepted,i also recommend to specify on the help pages,that 
there is no need to escape the args as it will done automatically.

--
keywords: +patch
nosy: +sahutd
Added file: http://bugs.python.org/file33859/issue20451.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-01-31 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20451] os.exec* mangles argv on windows (splits on spaces, etc)

2014-01-30 Thread Florian Bruhin

New submission from Florian Bruhin:

The os.exec* functions seem to mangle arguments on Windows. So far I noticed 
the supplied argv gets split on spaces, and double-quotes get stripped when not 
escaped.

Example, on Windows 7:

>>> platform.platform()
'Windows-7-6.1.7601-SP1'
>>> os.execlp('python', 'python', '-c', 
>>> "sys=__import__('sys');print(sys.argv)", 'Hello World')
['-c', 'Hello', 'World']

Same on Archlinux: ['-c', 'Hello World'] as expected.

Both running Python 3.3.3.

--
components: Library (Lib), Windows
messages: 209748
nosy: The Compiler
priority: normal
severity: normal
status: open
title: os.exec* mangles argv on windows (splits on spaces, etc)
type: behavior
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com