Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

_subprocess module removed in Python 3.3 #2471

Closed
gbrandonp opened this Issue · 1 comment

2 participants

@gbrandonp

In Python 3.3, there is no _subprocess, thus a couple of IPython.zmq related methods fail due missing import on Windows. The items imported were Windows specific API calls that the subprocess module used privately on Windows. The API calls are available via pywin32 (specifically from win32api, win32con and win32event modules), however that currently doesn't have a released version that works for Python 3.3, although current tip/trunk does work. Below is a patch which fixes the issue for Python 3.3 and likely works for the other versions of Python as well. The question is which of the following would be most preferable:

  1. should a dependency be added on pywin32 for just Python 3.3
  2. move away from the private _subprocess include for all versions and have pywin32 be a dependency for IPython on Windows, or
  3. find a mechanism, if possible, that removes the need for _subprocess or pywin32

There is already a dependency on pywin32, at least in some contexts (Parallel/HPC, others?), so it would seem that long-term, 2 is probably preferable.

diff --git a/IPython/zmq/entry_point.py b/IPython/zmq/entry_point.py
index dff9286..960fccb 100644
--- a/IPython/zmq/entry_point.py
+++ b/IPython/zmq/entry_point.py
@@ -189,8 +189,8 @@ def base_launch_kernel(code, fname, stdin=None, stdout=None, stderr=None,
                          creationflags=512, # CREATE_NEW_PROCESS_GROUP
                          stdin=_stdin, stdout=_stdout, stderr=_stderr)
         else:
-            from _subprocess import DuplicateHandle, GetCurrentProcess, \
-                DUPLICATE_SAME_ACCESS
+            from win32api import DuplicateHandle, GetCurrentProcess
+            from win32con import DUPLICATE_SAME_ACCESS
             pid = GetCurrentProcess()
             handle = DuplicateHandle(pid, pid, pid, 0,
                                      True, # Inheritable by new processes.
diff --git a/IPython/zmq/parentpoller.py b/IPython/zmq/parentpoller.py
index 5cf0b57..80f509b 100644
--- a/IPython/zmq/parentpoller.py
+++ b/IPython/zmq/parentpoller.py
@@ -100,7 +100,8 @@ def send_interrupt(interrupt_handle):
     def run(self):
         """ Run the poll loop. This method never returns.
         """
-        from _subprocess import WAIT_OBJECT_0, INFINITE
+        from win32con import WAIT_OBJECT_0
+        from win32event import INFINITE

         # Build the list of handle to listen on.
         handles = []
@minrk
Owner

it looks like the shortest route is to use the new _winapi module, which consolidated some scattered names.

@minrk minrk closed this issue from a commit
@minrk minrk use new _winapi instead of removed _subprocess
`_subprocess` is removed in Python 3.3, and the relevant names
relocated to a new `_winapi` module.

ref: http://bugs.python.org/issue11750

closes #2471

should be back ported to 0.13.1
c930eff
@minrk minrk closed this in c930eff
@minrk minrk referenced this issue from a commit
@minrk minrk Backport PR #2479: use new _winapi instead of removed _subprocess
`_subprocess` is removed in Python 3.3, and the relevant names relocated to a new `_winapi` module.

closes #2471

should be back ported to 0.13.1 because all zmq-based IPython will fail on win/py3.3 without it.

ref: http://bugs.python.org/issue11750
bbd4485
@mindw mindw referenced this issue from a commit in mindw/ipython
@minrk minrk Backport PR #2479: use new _winapi instead of removed _subprocess
`_subprocess` is removed in Python 3.3, and the relevant names relocated to a new `_winapi` module.

closes #2471

should be back ported to 0.13.1 because all zmq-based IPython will fail on win/py3.3 without it.

ref: http://bugs.python.org/issue11750
3860e3a
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@minrk minrk use new _winapi instead of removed _subprocess
`_subprocess` is removed in Python 3.3, and the relevant names
relocated to a new `_winapi` module.

ref: http://bugs.python.org/issue11750

closes #2471

should be back ported to 0.13.1
6b73f2a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.