From f95b37429fccf0cbe680f19c009c8a1600c4270d Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Wed, 7 Mar 2018 19:29:28 +0000 Subject: [PATCH] parent: Read preamble in first stage with os.fdopen() SSH command size: 439 (+4 bytes) Preamble size: 8941 (no change) This _increases_ the size of the first stage, but - Eliminates one of the two remaining uses of `sys` - Reads the preamble as a byte-string, no call `.encode()` is needed on Python 3 before calling `_()` --- mitogen/parent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 6e8d11b3..79b9454d 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -339,7 +339,7 @@ class Stream(mitogen.core.Stream): os.environ['ARGV0']=sys.executable os.execl(sys.executable,'mitogen:CONTEXT_NAME') os.write(1,'EC0\n') - C=_(sys.stdin.read(PREAMBLE_COMPRESSED_LEN),'zip') + C=_(os.fdopen(0,'rb').read(PREAMBLE_COMPRESSED_LEN),'zip') os.fdopen(W,'w',0).write(C) os.fdopen(w,'w',0).write('PREAMBLE_LEN\n'+C) os.write(1,'EC1\n')