From 3eda5ec671f641f4e3f1b0ee1c45e436763a2b0c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 21 Sep 2017 16:14:32 +0530 Subject: [PATCH] core: remove pointless eval() of ARGV0 environment variable. --- mitogen/core.py | 3 ++- mitogen/fakessh.py | 2 +- mitogen/master.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mitogen/core.py b/mitogen/core.py index 19a305a3..eb6701b1 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -657,6 +657,7 @@ class Stream(BasicStream): LOG.debug('%r.on_shutdown(%r)', self, broker) def accept(self, rfd, wfd): + # TODO: what is this os.dup for? self.receive_side = Side(self, os.dup(rfd)) self.transmit_side = Side(self, os.dup(wfd)) set_cloexec(self.receive_side.fd) @@ -1184,7 +1185,7 @@ class ExternalContext(object): self.router.register(self.parent, self.stream) - sys.executable, = eval(os.environ.pop('ARGV0')) + sys.executable = os.environ.pop('ARGV0', sys.executable) LOG.debug('Connected to %s; my ID is %r, PID is %r', self.parent, context_id, os.getpid()) LOG.debug('Recovered sys.executable: %r', sys.executable) diff --git a/mitogen/fakessh.py b/mitogen/fakessh.py index c1b2b7c9..71b9bd6f 100644 --- a/mitogen/fakessh.py +++ b/mitogen/fakessh.py @@ -384,7 +384,7 @@ def run(dest, router, args, deadline=None, econtext=None): env = os.environ.copy() env.update({ 'PATH': '%s:%s' % (tmp_path, env.get('PATH', '')), - 'ARGV0': `[sys.executable]`, + 'ARGV0': sys.executable, 'SSH_PATH': ssh_path, }) diff --git a/mitogen/master.py b/mitogen/master.py index e9cad282..a02caece 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -588,7 +588,7 @@ class Stream(mitogen.core.Stream): os.dup2(R,0) os.dup2(R2,101) for f in R,R2,W,W2: os.close(f) - os.environ['ARGV0'] = `[sys.executable]` + os.environ['ARGV0'] = sys.executable os.execv(sys.executable,['mitogen:CONTEXT_NAME']) else: os.write(1, 'EC0\n')