-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
Deprecate platform.popen() #55586
Comments
Extract of the documentation: platform.popen(cmd, mode='r', bufsize=None) Portable popen() interface. Find a working popen implementation preferring win32pipe.popen(). On Windows NT, win32pipe.popen() should work; on Windows 9x it hangs due to bugs in the MS C library. Python 3 doesn't support Windows 9x/Me anymore: we should deprecate it, or maybe directly remove it. subprocess.Popen() is a better alternative: it supports Unicode, it handles EINTR, etc. |
STINNER Victor wrote:
Does it prevent a shell window from opening on Windows ? Does subprocess.Popen() use the system's PATH for finding the Since it's a documented API, we could replace it with an implementation |
os.popen() is deprecated since Python 2.6 ("Use the subprocess module.") and it is no more documented in Python 3. The following documentation explains how to replace os.popen() by subprocess: http://docs.python.org/py3k/library/subprocess.html#replacing-os-popen-os-popen2-os-popen3
Yes, but only if shell=True.
Yes. The subprocess module calls os.get_exec_path() which reads PATH environment variable.
platform_popen.patch patchs platform.popen() to reuse os.popen() (which uses subprocess). It adds also tests (there was no test for platform.popen)
Can't we at deprecate platform.popen in favor of subprocess, with a documentation to explain how to port code to subprocess? My patch doesn't touch platform documentation. -- os.popen() does still exist in Python 3.2, but it is no more documented. Its documentation should be fixed or the function should be removed. |
STINNER Victor wrote:
One more question: Doe subprocess work from inside Windows GUI applications ? (I added the _popen class to work around issues with those
Hmm, but if os.popen() is no longer supported in Python 3, how can The os module still provides an popen() function which uses subprocess. The documentation for the os module says: http://docs.python.org/py3k/library/os.html?highlight=os#os.plock """
section File Object Creation. If you then go to the suggested section, there's no mention of os.popen(). The documentation should either be removed completely, or restored to
Sure, just not remove it immediately.
Indeed. See above. Thanks,Marc-Andre Lemburg ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 |
BTW: The _popen class can be removed as well, if the function |
You mean: Python embedded in another program? I don't know. How can I test that? I never see any warning in subprocess documentation saying that subprocess doesn't work on Windows in some cases. subprocess uses CreateProcessW() (by _subprocess.CreateProcess). I suppose that CreateProcessW() can always be used. Note: subprocess does still support Windows 9x. But there is an issue to drop this support: bpo-2405 (Drop w9xpopen and all dependencies). |
STINNER Victor wrote:
Try to use platform from within IDLE or PythonWin. The popen()
Probably yes, but it's better to check.
The platform module in Python3 no longer needs to support platforms Some background on the compatibility requirements of platform: The main reason for making platform portable across various Python For the Python3 branch, the same stability should be applied, but |
I tried subprocess.call('calc.exec'): it works. I tried p=subprocess.Popen('echo hello', shell=True, stdout=subprocess.PIPE); p.communicate(): it works too (I get the output and there is no MS-DOS popup).
platform.popen() and os.popen() have the same requirement: call process.wait() on file.close(). os.popen() does already implement that using _wrap_close. I don't want to copy/paste the code from os. os.popen() does still exist, why not reusing it? Anyway, if we remove os.popen(), we should remove platform.popen() too. But I don't want/plan to remove os.popen(). |
STINNER Victor wrote:
Great. Thanks for checking.
Ok. If you remove the _popen class as well, the patch can go in. |
New patch deprecating platform.popen() and removing _popen. Marc-Andre: Do you agree to deprecate platform.popen() in favour of subprocess? |
STINNER Victor wrote:
Patch looks good.
Yes. We can start the deprecation process in 3.3. Thank you,Marc-Andre Lemburg ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 |
Commited to 3.3 (r88721). |
Is it on purpose that there is a doc deprecation but no [Pending]DeprecationWarning? |
Éric Araujo wrote:
No, I guess just an oversight. |
haypo asked me on IRC if I’d like to make a patch for this; I will, in some weeks. With respect to the recent thread about deprecations and 2.7 → 3.<latest> migrations, should this be a DeprecationWarning or PendingDeprecationWarning? Neither is displayed by default, but using PDW would put the actual removal a version later. I’m not sure about the timeframe here. |
Éric Araujo wrote:
Please follow the PEP-387 guidelines. We are starting the deprecation |
New changeset e44b851d0a2b by Victor Stinner in branch 'default': |
Slight tangent: Regarding os.popen()'s [documentation] status, there's a bug for that: http://bugs.python.org/issue9382 |
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: