Gregory P. Smith added the comment:
A side effect of the changes made within are that getstatusoutput() on POSIX
systems now returns a different value for status.
The old implementation present in Python 2 and Python 3.3 before this patch
returned the raw waitpid() status result as the status
Gregory P. Smith added the comment:
http://bugs.python.org/issue23508 to track the fall out of that.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
Roundup Robot added the comment:
New changeset 34df43c9c74a by R David Murray in branch '3.3':
#10197: Update get[status]output versionchanged with actual version.
http://hg.python.org/cpython/rev/34df43c9c74a
New changeset ee277b383d33 by R David Murray in branch 'default':
#10197: Update
Tim Golden added the comment:
Thanks: final outdated comments removed
--
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
Arfrever Frehtes Taifersar Arahesis added the comment:
Lib/subprocess.py still has outdated comment:
# NB This only works (and is only relevant) for POSIX.
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
Terry J. Reedy added the comment:
Is this ready to be reclosed?
--
nosy: +terry.reedy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
___
Roundup Robot added the comment:
New changeset 0aa2aedc6a21 by Tim Golden in branch 'default':
Issue #10197 Tweak docs for subprocess.getstatusoutput and align the
documentation, the module docstring, and the function docstring.
http://hg.python.org/cpython/rev/0aa2aedc6a21
--
Roundup Robot added the comment:
New changeset c34e163c0086 by Tim Golden in branch '3.3':
Issue #10197 Rework subprocess.get[status]output to use subprocess
functionality and thus to work on Windows. Patch by Nick Coghlan.
http://hg.python.org/cpython/rev/c34e163c0086
New changeset
Tim Golden added the comment:
Code tests now work on Windows. Applied to 3.3 3.4.
--
resolution: - fixed
stage: test needed - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
Gregory P. Smith added the comment:
The documentation needs updating to state that these are available on Windows
(currently it says UNIX) with a versionchanged annotation.
http://docs.python.org/3.3/library/subprocess.html#legacy-shell-invocation-functions
--
nosy: +gregory.p.smith
Roundup Robot added the comment:
New changeset 2924a63aab73 by Tim Golden in branch '3.3':
Issue #10197: Indicate availability of subprocess.get[status]output on Windows
and add a note about the effects of universal newlines
http://hg.python.org/cpython/rev/2924a63aab73
New changeset
Tim Golden added the comment:
Good point. I've added the versionchanged tag.
The issue with bytes-string encoding goes all the way back to
Popen.communicate if universal newlines mode is used so I've simply put
in a reference to the existing notes on the subject higher up in the docs.
Changes by Tim Golden m...@timgolden.me.uk:
--
assignee: - tim.golden
versions: +Python 3.4 -Python 3.2
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
Tim Golden added the comment:
Patched according to Nick Coghlan's suggestion in
http://bugs.python.org/issue9922#msg150093. Ad hoc tests look ok on Windows.
I'll add tests look at *nix later.
--
Added file: http://bugs.python.org/file32450/issue10197.diff
Éric Araujo mer...@netwok.org added the comment:
I think that adding safer wrappers and deprecating things are valuable but
different bugs. In the short term, we could apply the proposed small patch to
just fix the issue at hand. Can one of the Windows experts weigh in?
The patch does this:
Nick Coghlan ncogh...@gmail.com added the comment:
Without knowing this issue existed, I recently started working on adding some
convenience APIs for shell invocation to shutil:
http://bugs.python.org/issue13238
I think the getstatus and getstatusoutput APIs were copied from the commands
Éric Araujo mer...@netwok.org added the comment:
IMO, both should be deprecated:
- they're not cross-platform
Isn’t the purpose of this report to fix that? :)
- they invoke the shell implicitly, which subprocess promises never to do
One could argue that it’s not implicit if it’s documented.
Changes by Florent Xicluna florent.xicl...@gmail.com:
--
nosy: +flox
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
___
Python-bugs-list
Éric Araujo mer...@netwok.org added the comment:
If Windows shell syntax is similar to POSIX one, then () will run in a
sub-shell, which would be a different behavior than using {} (which merely
group statements and their streams).
--
versions: -Python 3.1
bpoaugust sebbaz+...@gmail.com added the comment:
I got the () syntax from:
http://technet.microsoft.com/en-us/library/cc737438%28WS.10%29.aspx
which refers to grouping, not subshell.
--
___
Python tracker rep...@bugs.python.org
bpoaugust sebbaz+...@gmail.com added the comment:
subprocess.getoutput does not currently work at all on Windows.
So it's not necessary to maintain backwards compatibility.
The following fix works for me on WinXP/Python 3.2.2.
Replace
pipe = os.popen('{ ' + cmd + '; } 21', 'r') # line 613
bpoaugust sebbaz+...@gmail.com added the comment:
A better fix, which supports multiple windows commands:
if mswindows:
pipe = os.popen('( ' + cmd + ' ) 21', 'r') # Windows uses () rather
than { }
else:
pipe = os.popen('{ ' + cmd + '; } 21', 'r')
This works with the
Changes by bpoaugust sebbaz+...@gmail.com:
--
versions: -Python 3.3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
___
Python-bugs-list
Changes by STINNER Victor victor.stin...@haypocalc.com:
--
versions: +Python 3.3
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
___
STINNER Victor victor.stin...@haypocalc.com added the comment:
subprocess_getoutput.patch: patch subprocess.getstatusoutput() to use directly
Popen, instead of os.popen, with stderr=subprocess.STDOUT instead of 21
shell redirection. It strips also all trailing spaces and newlines, not just
STINNER Victor victor.stin...@haypocalc.com added the comment:
I tried to add a shell argument (to be able to disable the shell) and
to accept any Popen keyword, but I don't know how to implement
shell=False if the input is a list of arguments. list2cmdline() is
unsafe on UNIX (see #8972).
Éric Araujo mer...@netwok.org added the comment:
The question that remains is, does removing the {} change the output
obtained from a command sequence in any way?
{} are used to group output from the commands into one stream. I believe the
stdout and stderr arguments to Popen allow us to get
STINNER Victor victor.stin...@haypocalc.com added the comment:
-def getstatusoutput(cmd):
+def getstatusoutput(cmd, shell=True):
shell=True is dangerous, it can lead to shell command injection. I would prefer
to set its default value to False. The function already exists in Python 3.1,
but it
Éric Araujo mer...@netwok.org added the comment:
The function already exists in Python 3.1, but it is not used in Python
source code
We don’t know what code out there uses. This would be an incompatible change.
--
___
Python tracker
R. David Murray rdmur...@bitdance.com added the comment:
Ah, I did not realize that getstatusoutput was implemented using os.popen. I
thought it already used Popen. Now, in python3, os.popen is in turn
implemented using subprocess.Popen, so removing that level of indirection seems
sensible.
Ned Deily n...@acm.org added the comment:
See also Issue9922
--
nosy: +ned.deily
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
___
Éric Araujo mer...@netwok.org added the comment:
I think we should implement getstatusoutput and getoutput with Popen objects to
gain portability and avoid spawning subshells.
--
___
Python tracker rep...@bugs.python.org
R. David Murray rdmur...@bitdance.com added the comment:
Do you have in implementation in mind? I'm not clear how this would work.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
Éric Araujo mer...@netwok.org added the comment:
My idea is simply using Popen with appropriate args for stdout and stderr
instead of using a shell command with redirections:
--- Lib/subprocess.py (révision 86943)
+++ Lib/subprocess.py (copie de travail)
@@ -560,11 +560,7 @@
return
Éric Araujo mer...@netwok.org added the comment:
() is used to launch a command in a sub-shell and {} is used to group commands,
for example to set up a stream redirection for all commands in brackets.
--
nosy: +eric.araujo
___
Python tracker
New submission from jldm j_l_domen...@yahoo.com:
Hi, first of all sorry for my English.
On windows XP SP3, the following code:
import subprocess
subprocess.getoutput(dir)
returns
'{ is not recognized as an internal or external command,\noperable
program or batch file.'
I made a
R. David Murray rdmur...@bitdance.com added the comment:
Oddly, the test suite skips getoutput and getstatusoutput on windows with the
comment that the source says it is relevant only for posix, but the
documentation does not have 'availability: unix' tags. (It is also odd that
getoutput
Changes by Brian Curtin cur...@acm.org:
--
components: +Windows
nosy: +brian.curtin
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10197
___
___
38 matches
Mail list logo