Skip to content

Commit 844b3da

Browse files
RonnyPfannschmidtbluetech
authored andcommitted
gateway_io: remove Python 2 compat code
1 parent 44fd96e commit 844b3da

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

execnet/gateway_io.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,12 @@ def kill(self):
3232

3333
def killpopen(popen):
3434
try:
35-
if hasattr(popen, "kill"):
36-
popen.kill()
37-
else:
38-
killpid(popen.pid)
39-
except OSError:
40-
sys.stderr.write("ERROR killing: %s\n" % (sys.exc_info()[1]))
35+
popen.kill()
36+
except OSError as e:
37+
sys.stderr.write("ERROR killing: %s\n" % e)
4138
sys.stderr.flush()
4239

4340

44-
def killpid(pid):
45-
if hasattr(os, "kill"):
46-
os.kill(pid, 15)
47-
elif sys.platform == "win32" or getattr(os, "_name", None) == "nt":
48-
import ctypes
49-
50-
PROCESS_TERMINATE = 1
51-
handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, pid)
52-
ctypes.windll.kernel32.TerminateProcess(handle, -1)
53-
ctypes.windll.kernel32.CloseHandle(handle)
54-
else:
55-
raise OSError(f"no method to kill {pid}")
56-
57-
5841
popen_bootstrapline = "import sys;exec(eval(sys.stdin.readline()))"
5942

6043

@@ -72,10 +55,8 @@ def shell_split_path(path):
7255
def popen_args(spec):
7356
args = shell_split_path(spec.python) if spec.python else [sys.executable]
7457
args.append("-u")
75-
if spec is not None and spec.dont_write_bytecode:
58+
if spec.dont_write_bytecode:
7659
args.append("-B")
77-
# Slight gymnastics in ordering these arguments because CPython (as of
78-
# 2.7.1) ignores -B if you provide `python -c "something" -B`
7960
args.extend(["-c", popen_bootstrapline])
8061
return args
8162

0 commit comments

Comments
 (0)