classification
Title: subprocess.py doesn't correctly detect Windows machines
Type: behavior Stage: test needed
Components: Library (Lib), Windows Versions: Python 3.2, Python 3.1, Python 2.7, Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, brian.curtin, dino.viehland, midnightdf, pitrou, r.david.murray
Priority: normal Keywords: patch

Created on 2010-03-10 15:57 by midnightdf, last changed 2010-11-28 20:14 by brian.curtin.

Files
File name Uploaded Description Edit
issue8110_subprocess_mswindows.diff flox, 2010-03-10 16:28 Patch, apply to 2.x review
Messages (12)
msg100788 - (view) Author: Dave Fugate (midnightdf) Date: 2010-03-10 15:57
subprocess.py contains the following line (380 in CPython 2.6.3):
    mswindows = (sys.platform == "win32")

which only correctly detects CPython on Windows.  This line should be changed to:
    mswindows = (sys.platform == "win32" or sys.platform == "cli" or sys.platform == "silverlight")

so subprocess can be utilized from IronPython as well.

This bug should be trivial to fix.
msg100789 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-03-10 16:13
Probably it should use platform.system() == 'Windows' instead.
msg100790 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-03-10 16:16
but, does it work even with your fix?
it seems to me that "from _subprocess import *" will fail miserably.
msg100791 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-03-10 16:19
Also, using platform.system() == 'Windows' would exclude IronPython running on Mono.
msg100793 - (view) Author: Dave Fugate (midnightdf) Date: 2010-03-10 16:22
platform.system()=="Windows" won't work unless you change platform as well:
IronPython 2.6.1 DEBUG (2.6.10920.0) on .NET 2.0.50727.4927
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.system()
'cli'
msg100794 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-03-10 16:26
it's not about platform detection; does IronPython have the equivalent of msvcrt.open_osfhandle()?
msg100795 - (view) Author: Dave Fugate (midnightdf) Date: 2010-03-10 16:27
Is there any reason _subprocess couldn't be implemented in C#?  If not, this is the first of many steps needed to get subprocess working under IronPython.
msg100796 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-10 16:28
Proposed patch, with duck subprocessing. :D
msg100798 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-03-10 16:39
Amaury is right. On Windows, _subprocess is a built-in, so the platform stuff just currently enables further failure.

Dave: My C# skills aren't the greatest, but looking at PC/_subprocess.c there are a few Win32 functions you might need to P/Invoke, but I believe a lot of the functionality is supported in .NET.
msg100957 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-03-12 19:03
Florent's patch makes sense to me.
msg100978 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-03-12 22:24
What does the patch achieve?
msg122717 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2010-11-28 20:14
Jeff Hardy just made this change for IronPython 2.7: http://bitbucket.org/ironpython/ironlanguages/changeset/b6bb2a9a7bc5

Any opposition to us matching that so they don't need to patch Lib/subprocess.py?
History
Date User Action Args
2010-11-28 20:14:54brian.curtinsetmessages: + msg122717
2010-08-08 21:00:25floxsetnosy: - flox
2010-03-12 22:24:18amaury.forgeotdarcsetmessages: + msg100978
2010-03-12 19:05:39michael.foordsetnosy: - michael.foord
2010-03-12 19:03:46pitrousetnosy: + pitrou
messages: + msg100957
2010-03-10 16:39:40brian.curtinsetkeywords: - easy

messages: + msg100798
2010-03-10 16:28:21floxsetfiles: + issue8110_subprocess_mswindows.diff
keywords: + patch
messages: + msg100796
2010-03-10 16:27:57midnightdfsetmessages: + msg100795
2010-03-10 16:26:39amaury.forgeotdarcsetmessages: + msg100794
2010-03-10 16:22:10midnightdfsetmessages: + msg100793
2010-03-10 16:19:28brian.curtinsetnosy: + brian.curtin
messages: + msg100791
2010-03-10 16:16:22amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg100790
2010-03-10 16:13:26r.david.murraysetkeywords: + easy
nosy: + dino.viehland, r.david.murray, michael.foord
messages: + msg100789

2010-03-10 16:12:08floxsetnosy: + flox
2010-03-10 16:04:31brian.curtinsetpriority: normal
versions: - Python 3.3
components: + Windows
stage: test needed
2010-03-10 15:57:12midnightdfcreate